core-async

dabrazhe 2019-12-08T10:53:06.272300Z

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.

mccraigmccraig 2019-12-08T13:55:37.273900Z

@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

dabrazhe 2019-12-08T17:38:09.276900Z

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

2019-12-08T18:14:15.277400Z

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

2019-12-08T18:15:41.278800Z

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

2019-12-08T18:16:06.279600Z

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

2019-12-08T18:17:13.280400Z

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

2019-12-08T18:38:39.280700Z

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!

2019-12-08T18:40:31.281Z

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

2019-12-08T21:49:10.284700Z

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

2019-12-08T21:56:36.284900Z

Thanks, I'll try that!

2019-12-08T22:20:27.285300Z

I think that worked perfectly? Great!

2019-12-08T22:57:14.288900Z

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

👍 1