Fork me on GitHub
#core-async
<
2019-12-08
>
dabrazhe10:12:06

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.

mccraigmccraig13:12:37

@dennisa haven't tried it myself, but i think you can return a promise as the result of your lambda (see "async functions" https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html ), and then you can resolve or reject that promise in your core.async take! callback

dabrazhe17:12:09

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

hiredman18:12:15

_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._

hiredman18:12:41

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

hiredman18:12:06

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

hiredman18:12:13

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

hiredman21:12:10

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!

hiredman22:12:14

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