Fork me on GitHub

Yes, it does indeed. But when take finishes it returns nil, which is the value the handler return, therefore my Lambda returns nil. (handler (take! ch #(callback %))) returns nil, the callback result is lost in the process.


@dennisa haven't tried it myself, but i think you can return a promise as the result of your lambda (see "async functions" ), and then you can resolve or reject that promise in your core.async take! callback


Yes, you right, you can return a promise to the handler, eg as a result of a http request. But how can I read from channel and make it to return a promise outside of the channel chain in cljs? Promise will be the value in this case, while a go block will just return a channel


_The third argument, callback, is a function that you can call in non-async functions to send a response. The callback function takes two arguments: an Error and a response. The response object must be compatible with JSON.stringify. For async functions, you return a response, error, or promise to the runtime instead of using callback._


(they seem to be using the word async in the reverse of what I would expect)


Anyway, the handler doesn't need to return anything, just call the callback


Ah, they mean literally functions tagged with async keyword in js

Sam Ferrell18:12:39

I'm having some trouble with this design. I'm writing a CLJS app and trying to mimic something like re-frame or CycleJS. I'm flexible on the design, just need some direction to satisfy this problem. Thanks!

Sam Ferrell18:12:31

I'm pretty confident I know why its not working, just seeing if there's an established idiomatic approach to this


Events needs to be a mult and each if your pubs needs to tap it, otherwise each event only goes to a single pub

Sam Ferrell21:12:36

Thanks, I'll try that!

Sam Ferrell22:12:27

I think that worked perfectly? Great!


It seems like a version of pub where topic-fn returns a seq of topics instead of a single topic would allow you to model sort of hierarchical or wild card pubsub

👍 4