Fork me on GitHub
#clojurescript
<
2016-03-12
>
george.w.singer00:03:47

Let c be a channel and suppose that L is the list '(>! c 5). Is it possible in clojurescript to do something like (apply go L) so that the end result is a channel c with the value 5 shoved into it? I know that you cannot literally say (apply go L) since go is a macro and therefore cannot be used with apply. Moreover, I know that clojurescript doesn't have eval so you cannot just say (eval (conj L 'go)).

george.w.singer00:03:24

So is there a way to achieve this effect without the usage of apply and eval?

richiardiandrea00:03:47

I read somewhere that partial is slow in clojurescript and I am wondering in which way and if a curried function is better, but maybe I am just worrying too much

richiardiandrea00:03:20

I see from the source that partial is basically creating a fn with 5 arities

richiardiandrea00:03:46

any thought on this?

jrheard05:03:31

@richiardiandrea: try benchmarking it!

jrheard05:03:40

(sorry, i don't know the answer - i've been profiling/benchmarking my cljs app all day, so that's where my mind is)

richiardiandrea05:03:13

@jrheard is there an equivalent to criterium for ClojureScript? Sorry I haven't even googled yet :)

nxqd09:03:48

hi guys I have this kind of errors while using cljsbuild to build production javascript :

ERROR: JSC_MISSING_PROVIDE_ERROR. required "my_project.projects.project_page" namespace never provided at /Volumes/Data/dev/cljs-housing/resources/public/js/production/aaa/components/app.js line 9 : 0
ERROR: JSC_MISSING_PROVIDE_ERROR. required "my_project.utils.browser_settings" namespace never provided at /Volumes/Data/dev/cljs-housing/resources/public/js/production/aaa/core.js line 4 : 0
ERROR: JSC_MISSING_PROVIDE_ERROR. required "my_project.utils.browser_settings" namespace never provided at /Volumes/Data/dev/cljs-aaa/resources/public/js/production/my_project/landing/page.js line 5 : 0
I don't know what kind of this error is, since I'm pretty sure that the namespace is there ( it works in dev )

pez09:03:22

Super awesome, @bhauman! Maybe some line numbers would help?

darwin11:03:21

@george.w.singer: I’m afraid it is not possible. go generates code during compilation phase (yeah that’s the definition of a macro). You cannot feed it with dynamic L and expect it to generate code at runtime (without using eval). Not sure about your use-case, but if you are able to generate L during compilation phase you could write a macro which would apply go to "L-expanded-at-compile-time". Something along these lines where gen-body is another macro, which looks at L during compilation and generates body forms from it somehow, e.g. using some naming conventions or using some compile-time tables etc.:

(defmacro apply-go[body-spec]
  (let [body (gen-body body-spec)]
    `(go [email protected])))
Basically you would need to move all logic related to body construction from L to macros.

martinklepsch16:03:16

looking for a react thing that helps with inline autocompletion like @nick and #channel in Slack — any one a recommendation?

amacdougall18:03:30

So this does appear to work, but it's pretty gross. Is there a Location or URI method I'm missing, to get the full URL before the pathname in a single step?

(defn- token
  "Generate a 'token' compatible with goog.history.Html5History. Basically a full URL."
  [path]
  (let [location (.-location js/window)
        base (str (.-protocol location) "//" (.-host location))]
    (str base path)))

(defroute home "/admin" []
  (.setToken @history (token "/admin"))
  (re-frame/dispatch [:display-home])) ; the re-frame stuff works fine
I need the full URL, because otherwise it tries to set the history state to —evidently there are no relative states.

amacdougall18:03:39

(I'm also open to a better way of adding a history state and setting window.location! The history atom in this code is an instance of goog.history.Html5History.)

amacdougall18:03:18

@martinklepsch: What's your opinion of the various Google results for "react autocomplete"? You might be able to integrate one of those JS projects into your code.

pez18:03:46

@amacdougall: not sure about your use case, but it sounds like you could use Accountant.

amacdougall18:03:55

Good recommendation, @pez. My code more or less does the same thing, but probably worse. I'll check out the Accountant source and see what I can learn from it.

pez18:03:44

There is also pushy

martinklepsch18:03:01

@amacdougall: most of them are for input fields and don't seem to be suitable for textareas/token-triggred autocompletion

amacdougall18:03:14

Ah, I see what you mean. I don't know—it might not be that hard to implement. You just have to handle the token by starting your autocomplete routine. I know that saying "you just have to" is usually a preface to something deceptively difficult...

amacdougall18:03:18

@pez: I tried just throwing Accountant into my code, and it worked right off the bat. Great stuff, thanks!

pez18:03:13

@amacdougall: I agree. It just does the right thing. CC: @venantius