re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
2021-01-21T05:05:06.001Z

I've got a question about the best way to chain requests in re-frame land. I'm dealing with an api that requires multiple POSTs in sequence, with each one building on the result of the previous.

2021-01-21T05:06:08.001900Z

Is there a good pattern for this? Manually chaining together events seems a bit fragile

2021-01-21T05:24:06.003500Z

to elaborate: I've got to create topic a, post message 1 to topic a, post message 2 referencing message 1 to topic b

2021-01-21T05:24:47.004100Z

Now, I've got a generic create-topic event handler, and a generic send-message event handler, as those are used all over the place.

2021-01-21T05:25:58.005200Z

And at each step I've got to hook in to the flow in a generic way to track requests, updating request status and loading spinners, etc.

2021-01-21T05:26:25.005700Z

So the chain of events is becoming quite long, and I worry that I'm going to have trouble figuring out how it all works in 6 months

2021-01-21T05:28:40.006500Z

And the thing that keeps poking me is that this can be done with ~10 lines of code with async/await style js, and I'm not sure how to translate it.

Fredrik Andersson 2021-02-02T17:27:57.031800Z

Maybe https://github.com/ingesolvoll/re-chain ?

lassemaatta 2021-01-21T06:05:59.007Z

I'm not confident enough to say that this is the best way, but I remember using https://github.com/day8/re-frame-async-flow-fx to achieve something similar

2021-01-21T06:30:23.007300Z

thanks, I'll check that out

Schpaa 2021-01-21T23:21:38.009600Z

@datran kee-frame has a rudimentary state machine which I’ve personally found very helpful in situations like you describe.