shoreleave / shoreleave-remote-ring Goto Github PK
View Code? Open in Web Editor NEWRing- (& Compojure-) friendly remote functions for use w/ shoreleave + ClojureScript
Ring- (& Compojure-) friendly remote functions for use w/ shoreleave + ClojureScript
The shoreleave.*
namespaces are all preferred now, but the docs don't reflect that. The biggest impact is that cemerick.shoreleave.rpc
has a default URI of /_fetch
, whereas shoreleave.middleware.rpc
uses /_shoreleave
. This will cause 404's when the old namespaces are used in conjunction with the standard shoreleave remote stuffs.
Hi Paul,
I will appreciate if you can help me get this to work.
I have included the shoreleave dependencies in my project.clj -
[shoreleave "0.3.0"]
[com.cemerick/shoreleave-remote-ring "0.0.2"]
[shoreleave/shoreleave-remote "0.3.0"]
Following is the code from my cljs file -
(ns mashup.core
(:use [webfui.framework :only [launch-app]]
[webfui.utilities :only [get-attribute clicked]])
(:use-macros [webfui.framework.macros :only [add-dom-watch add-mouse-watch]])
(:require [clojure.browser.repl :as repl])
(:require-macros [shoreleave.remotes.macros :as macros]))
(macros/letrpc data (fetch-data)
(js/alert data))
Below is the generated code from my cljs -
goog.provide("mashup.core");
goog.require("cljs.core");
goog.require("webfui.framework");
goog.require("webfui.utilities");
goog.require("clojure.browser.repl");
goog.require("webfui.utilities");
goog.require("webfui.framework");
shoreleave.remotes.http_rpc.remote_callback.call(null, "fetch-data", cljs.core.PersistentVector.EMPTY, function(data) {
alert("hello");
return alert(data)
});
And chrome gives me the following error - Uncaught ReferenceError: shoreleave is not defined
I am perplexed, I have included the shoreleave require, so also why doesnt it show up in the goog.require ?
defremote
does not support, as fn
and its derivatives (e.g. defn
) do, the conditional-map that allows to validate input/output with assertion.
Sample:
(defremote calculate [quantity price tax discount]
(-> (* quantity price)
(* (+ 1 (/ tax 100)))
(- discount)))
(defremote calculate [quantity price tax discount]
{:pre [(>= quantity 0)
(>= price 0)
(and (>= tax 0) (<= tax 100))
(<= discount (* quantity price (+ 1 (/ tax 100))))]}
(-> (* quantity price)
(* (+ 1 (/ tax 100)))
(- discount)))
It could be very useful for defremote to support conditional-map.
A global grab-bag of remotes makes it impossible to segregate them for various purposes; gh-3 w.r.t. arguments and returns, but plenty of other more common use cases (e.g. authorization, roles, etc) demand a tighter rein on what is callable.
I think the parenthesis is misplaced.
...
(catch Exception e
(throw
(Exception. (str "Could not locate a namespace when aliasing remotes: " namesp-sym))
e))
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.