-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Asynchronous action feedback / chaining #96
Comments
Hi! I do not understand why the post-dispatch effect or even the current API don't work. Can't you do? ModelResult update(Model m, SomeAction)
{
return { m, [](auto &&ctx) {
lager::get<SomeAsyncHandler>(ctx).someAsyncRequest()
.then([=](auto res) { ctx.dispatch(UpdateModelAccordingly{res}); });
} };
}
ModelResult update(Model m, UpdateModelAccordingly)
{
// update model...
return { m, [m](auto &&ctx) { // <-- capture here the model or parts you need
// more processing
ctx.dispatch(SomeOtherAction{<some data from model>})
} };
} |
I think it would be fair though to consider changing the API such that you know the resulting model after an action has been delivered: store.dispatch(some_action{})
.then([](auto ctx, auto model) {
// more effects depending on action having been deliverd
}); The problem is that while we can implement that for |
I would like to understand a bit better the use-case. In general I am a bit wary of adding too powerful API's in effect land, because with too much power comes 🍝 code 😂 |
To pinpoint a specific use case I would say the flow of sending an encrypted message in matrix, as follows:
I am now using a hacky way to implement this flow -> https://gitlab.com/kazv/libkazv/-/blob/af7a7fef79ef4a58485816c2561aa0ab51798a51/src/client/sdk-model.cpp . Comparing to what matrix-nio does: The reason I do not want Thank you again for your help. |
Kind of solving it by making another type of store. https://gitlab.com/kazv/libkazv/-/blob/servant/src/tests/store-test.cpp |
That's super cool. Hopefully I can take a look at it more deeply soon... maybe we can reconcile the differences and integrate something like that in Lager! |
We now obtain the member list of the room if the members are not fully loaded yet, and query for their identity keys. Thus we can send them encrypted messages without manually refreshing member list. Although in a hacky way. See also arximboldi/lager#96
Assume we have some action that performs some async tasks:
And we want to perform some other action after
UpdateModelAccordingly
has run. Here, using post-dispatch effect would not work as we would be processing according to the model, which it does not provide. The flow is roughly like:In traditional way it may be like
Although it is possible to use wrapper actions for that, but it is cumbersome when the flow gets longer (3-4 requests).
Another solution may be to use lambdas as actions, but then they are no longer good value types.
Is there a better solution for this? Thank you.
The text was updated successfully, but these errors were encountered: