Fork me on GitHub
#re-frame
<
2016-06-03
>
vikeri12:06:02

Would be pretty awesome to extend the re-frame tracing to work with this: https://github.com/skellock/reactotron

vikeri12:06:48

I opened an issue, so if you think it looks as awesome as I think, go and thumb it up šŸ˜‰ https://github.com/skellock/reactotron/issues/57

caio14:06:24

anyone doing polling in re-frame? looking for a good pattern/library to do it with events and core.async

richiardiandrea14:06:34

@caio my two cents: in your init handler you setup setTimeout dispatch (and maybe setting state in the db). Or if you use mount you can wrap it in a defstate. I like to handle start and stop through events though...

caio14:06:42

thatā€™s what iā€™m going for, but iā€™m seeing some bad concurrency issues, so i thought itā€™d be better to stop and ask here if someone solved this already

mccraigmccraig15:06:01

@caio: what sort of concurrency issues ?

caio15:06:20

when starting/stopping it with events. two start events happening at the same time, for instanceā€¦ but thatā€™s probably my fault, as I wanted to keep the timeout channel inside the app-db

mccraigmccraig15:06:50

@caio: don't put anything which isn't simple data into the app-db - it makes for an easier life in the end. in the past, i've done something like keeping a registry of polling request control-channels somewhere, each associated with a go-block which loops polling with a timeout until it receives a stop message/close on the control channel...

caio16:06:35

how lots of go-blocks are handled by javascript? afaik, js runs on a single thread, right?

mccraigmccraig17:06:12

@caio: yes - go blocks are transformed into a state-machine and run fine on a single thread

caio17:06:12

good to know that, but this way Iā€™ll have to create global vars to store the channels, and that makes me sad šŸ˜ž

mccraigmccraig20:06:35

@caio: a single global atom with a map with url-keys and channel-values - not so bad for clojure-land šŸ™‚

caio21:06:41

itā€™s introducing a singleton and all its issues into my pretty little functional code (channels will be the singletons). I guess Iā€™ll go ā€œlet over lambdaā€ to try and minimize this issue, but I was really hoping that there was a functional way out of this

javazquez21:06:38

having an issue in a handler where the ratom I am expecting is cljs.core/PersistentArrayMap so getting Uncaught Error: No protocol method ISwap.-swap! defined for type cljs.core/PersistentArrayMap any Ideas? handler below (re-frame/register-handler :add-to-want-list (fn [db [_ item-js-obj]] (swap! db assoc-in [:want-list] item-js-obj) )) if I provide the following ... it works (swap! re_frame_ui.db.default-db assoc-in [:want-list] item-js-obj) dispatching via an anchor tag

darwin21:06:12

@javazquez: db in handler is not your app-db atom, it is its naked value

darwin21:06:52

you are supposed to return a new value from the handler, re-frame will do the job of swapping in new value

javazquez21:06:03

there must be some inconsistancy

javazquez21:06:18

because another handler I wrote fails

javazquez21:06:29

Error: No protocol method IAssociative.-assoc defined for type reagent.ratom/RAtom: [object Object]

javazquez21:06:43

when I don't use swap

darwin21:06:52

btw. handlers are supposed to be pure, if you happend to be calling anything with exclamation mark inside your handler fn, you are doing it wrong, very wrong šŸ™‚

darwin21:06:50

I would bet you swap!ā€™d some atom into you app-db, and you created this inconsistency yourself, so your situation is app-db: <ratom value:<ratom: some other value>>

javazquez21:06:55

I have been bouncing through reagent docs and other docs and must have pulled in the wrong stuff

javazquez21:06:21

I bet your are absolutely correct

darwin21:06:25

are you familiar with cljs-devtools?

darwin21:06:42

it would be crystal clear, if you logged app-db atom into console

darwin21:06:53

(with cljs-devtools enabled)

javazquez21:06:32

ok.. <runs to read up and implement>

darwin21:06:40

have to go, good luck!

javazquez22:06:57

@darwin: : Looks my real issue was that I made the default-db a ratom. Once I changed to a map and made handlers pure.. I am making progress. Thanks for the cljs-devtools suggestion. It is really nice!