Fork me on GitHub
#clojurescript
<
2016-04-01
>
bpicolo02:04:48

So I'm just getting started with re-frame. What's the best time to load data for a page load?

bpicolo02:04:01

not clear to me what pattern is expected

bpicolo02:04:17

i.e. /foo/1 should load my first foo

bpicolo02:04:22

via the api to display

cky02:04:49

@bpicolo: So, upon landing on /foo/1, you’d dispatch an event to load your first foo. Your event handler for loading foo will then return an updated app-db at some unspecified point in future, at which point your subscribers (that have reactions) will process the newly-loaded data, which then flow on to your views that use the subscriptions. simple_smile

cky02:04:55

OMG, that was a mouthful.

bpicolo02:04:22

@cky: so in the "panel" context

bpicolo02:04:36

(why they decided on a new name for view I'm unsure)

cky02:04:53

I don’t understand what you just said, but okay. 😛

bpicolo02:04:33

@cky I guess the question is, there's many places I can put it such that it will dispatch upon routing. How can I make sure it only runs the one time I need it to?

bpicolo02:04:41

something akin to reacts getInitialState I suppose

cky02:04:09

So, the documentation talks about a special init event you can define, that works just like getInitialState.

bpicolo02:04:53

Yeah, I have that, but the init event is sort of app-wide

bpicolo02:04:56

rather than per-route

cky02:04:10

being the author of re-frame and all. 😉

mikethompson02:04:38

@bpicolo: there's a re-frame channel which might be a better forum for this > Your event handler for loading foo will then return an updated app-db at some unspecified point in future That's not really correct. The event handler returns immediately after firing off an HTTP GET. The callbacks for the HTTP GET will run at some point in the future, themselves further dispatching.

bpicolo02:04:05

Aha, heading there

escherize02:04:52

To my mind, the best answer to reference is in the books at: https://github.com/Day8/re-frame/wiki/Talking-To-Servers

jimmy03:04:25

hi guys what is the equiv of function? in Clojurescript ?

jimmy03:04:29

@cky: thanks 😄

danielgrosse06:04:59

@martinklepsch: Could you share you're solution, how you implemented raven?

martinklepsch08:04:31

@danielgrosse: the code above was ok, with the cljsjs/raven package and a (:require [cljsjs.raven]) things started working simple_smile

trikitrok09:04:42

I was wondering why this implementation of IPrintWithWriter does not work in my tests

trikitrok09:04:05

whereas if I use in this other way it works

dialelo09:04:59

make sure you're requiring the namespace where the extend-protocol is defined in your tests @trikitrok

trikitrok09:04:05

Thanks @dialelo Sorry I don't understand you The extend-protocol one is working fine. It's the first one that does not work...

dialelo09:04:36

sorry i misunderstood, i don't see any problem with the defrecord version

dialelo09:04:47

it should work perfectly

dialelo09:04:34

are you using a recent version of ClojureScript?

trikitrok09:04:23

Yes, I think

trikitrok09:04:46

We're changing how the Operation is printed to make the test errors output readable, but only the version in the second snippet works

trikitrok09:04:13

Which puzzles me completely...

trikitrok09:04:24

If you use extend-type it also works

trikitrok09:04:23

I've read that extend-type and extend-protocol have in common that they extend the protocol dynamically whereas defrecord is creating an object (I think..??)

trikitrok09:04:54

but I don't see why it doesn't behave in the same way...

nberger11:04:26

@trikitrok it seems like defrecord concats default implementations of some protocols to those provided by you in the defrecord, and one of them is IPrintWithWriter: https://github.com/clojure/clojurescript/blob/f057e3cdd7490faeba824920d8b48b80aac69a87/src/main/clojure/cljs/core.cljc#L1693

nberger11:04:09

I wonder why it's not done the other way around, so you could provide your own impl

trikitrok11:04:50

Thanks a lot @nberger And then that default implementation gets used instead of the one I provided, I see.

nberger11:04:18

Yep, it seems so

nberger11:04:34

It would be nice if there was a warning about your impl being overwritten, no?

trikitrok11:04:44

Maybe there's one and I didn't check..

stepugnetti14:04:51

Hi! Has anybody tried to use https://github.com/aksonov/react-native-router-flux with Reagent? The router component throws an error: component property is not set for key=root, but I don’t understand why. I mean, I gave a look at the source and I fund the relevant assertion, but I think I have correctly set the property that causes the assertion fail...

kenzaburo17:04:41

Are there any examples out there on how to setup automated cross-browser testing for cljs projects with services like Browserstack or Sauce Labs?

octahedrion17:04:54

hi, I've started getting compilation errors with latest clojurescript like :cause Invalid :refer, var var thing/thing does not exist in file /qweqe/qweqe, which aren't valid because if I delete the target js dir & build it's fine...but then on subsequent builds totally random errors like that

dnolen17:04:35

@octo221: make sure target isn’t on your classpath for some reason

octahedrion17:04:10

@dnolen: got it! it's :parallel-build true

octahedrion17:04:00

if I use :parallel-build true then I get error on subsequent builds after a first clean one

dnolen17:04:27

well you have to be certain that are your libraries are actually requiring things properly

octahedrion17:04:30

(no errors with false)

octahedrion17:04:45

will check....

dnolen17:04:46

I haven’t heard many bug reports about :parallel-build true

dnolen18:04:07

the reproducible issues I’m aware of have been addressed

dnolen18:04:31

not saying there isn’t an issue - but would need a real minimal case - not going to look at projects

octahedrion18:04:25

wait a minute...some of these missing var errors are for vars in the same namespace

octahedrion18:04:00

WARNING: Use of undeclared Var qwe.ui.core/reset-keypath at line 173 src/qwe/ui/core.cljc

octahedrion18:04:48

will make a copy of project & strip it down...

nberger18:04:57

@kenzaburo no specific examples that I know of, but I'd go using selenium via clj-webdriver. Browserstack has a guide on setting it up with java https://www.browserstack.com/automate/java that might be of help

lewix18:04:17

@dnolen: I was reading your article about lambda conf..sad

dnolen18:04:48

@lewix: no desire to talk about that stuff here - thanks simple_smile

darwin18:04:13

@octo221: I have also experienced intermittent problems with :parallel-build true in my projects 😞 those setups are rather complex and I never got to investigating the root cause

darwin18:04:42

even without parallel-build sometimes I end up with corrupted builds - for example with figwheel’s hot-reloading when I modify some macro file which triggers long re-compilation and I then modify that macro again before previous build finishes. I assume this triggers another build which gets clobbered by the previous one still running.

darwin18:04:06

this usually happens when I have some library dependency in lein’s checkouts dir and I touch some file there

macrobartfast18:04:12

how can I evaluate several forms in a buffer in emacs TTY and cider (all I really know to do in a buffer is eval the preceding form with C-c C-e)?

nberger18:04:21

I couldn't make :parallel-build to work on my project either, I couldn't get it to compile correctly even once, but didn't have time to investigate. I usually saw compilation errors with cljs-time, but also with core.async. It could be something wrong in our code, of course, I plan to play with it soon

dnolen18:04:59

@nberger: more information is always good, I have core.async in a project with :parallel-build and I haven’t see that

macrobartfast19:04:22

similarly, I'd like at times to eval a nested expression, and not the enclosing expressions.

dnolen19:04:09

@nberger that said you definitely need to be >=1.8.34

dnolen19:04:17

a nasty bug got addressed with that release

nberger19:04:45

@dnolen yes, I tried on 1.8.34 a few days ago, similar issues. I'll get better information and come back here

nberger22:04:47

@dnolen I have more information about the parallel-build issue: it happens in reagent, and I think it's related to some macros there. I created an issue with more details https://github.com/reagent-project/reagent/issues/225. @darwin do you remember if you were using reagent when you got those "intermittent compilation" issues?

dnolen22:04:51

@nberger that’s useful information, I have to run but feel free to drop info in #C07UQ678E if it seems like there’s something that could use fixing in ClojureScript itself

nberger22:04:59

I don't have a minimal repro yet, but at least this is smaller than my entire project 😄

darwin23:04:40

@nberger: I’m afraid, no reagent in my case

domkm23:04:02

Anyone know of a library that provides destructuring for JS objects?