Re: add-watch and writing data into a core.async channel

2015-07-31 Thread Raymond Huang
Thanks everyone for the suggestions, I'll try it out later today @leon Thanks. I wish this were documented in the API for how to write Clojure/Script compatible code. Just saw your answer on stackoverflow

Re: add-watch and writing data into a core.async channel

2015-07-31 Thread Timothy Baldridge
One "gotcha" is that atoms add-watches do not always guarantee order semantics. So if you have a watch put [old-val new-val] on a channel, and your atom operation is something like (swap! a inc), you may see values in your channel like this: [0 1] [2 3] [1 2] [3 4] [6 7] [4 5] This is because the

Re: add-watch and writing data into a core.async channel

2015-07-31 Thread Stefan Kamphausen
On Friday, July 31, 2015 at 8:21:18 AM UTC+2, Raymond Huang wrote: > > I'd like to use `add-watch` on an atom which writes the data to a > core.async channel. So far, I've come up with this, but it seems bad > because I create a new go-routine everytime something happens. > > Makes me think, one

Re: add-watch and writing data into a core.async channel

2015-07-31 Thread Leon Grapenthin
Use put! On Friday, July 31, 2015 at 8:21:18 AM UTC+2, Raymond Huang wrote: > > I'd like to use `add-watch` on an atom which writes the data to a > core.async channel. So far, I've come up with this, but it seems bad > because I create a new go-routine everytime something happens. > > (add-watch

add-watch and writing data into a core.async channel

2015-07-30 Thread Raymond Huang
I'd like to use `add-watch` on an atom which writes the data to a core.async channel. So far, I've come up with this, but it seems bad because I create a new go-routine everytime something happens. (add-watch ref watch-id #(go (a/>! user-changes %&))) This seems like a bad idea to me because I