Skip to content
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

orders.perform_cmd(...) and orders.msg_sender()(...) vs rendering #656

Open
wkordalski opened this issue Mar 9, 2022 · 2 comments
Open

Comments

@wkordalski
Copy link

Intuitively, returning () or None from future passed to orders.perform_cmd(...) means that no message should be sent to Seed mailbox.
Similarly, orders.msg_sender()(None) should not send any message.
And in these cases rerender should not be triggered.

But it is done differently. This is stated in documentation of seed::app::App::update_with_option.
However from library user perspective there's no connection between update_with_option and perform_cmd.

I think, we should at least state this fact in documentation of perform_cmd and msg_sender, so other library users won't be surprised like I was and won't have to spend time on debugging like I had to.


My code looked like:

fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
    match msg {
        Msg::MyMsg => {
            orders.perform_cmd(async move { /* do sth that do not require rerender */; });
            orders.after_next_render(|_| Msg::MyMsg);
            orders.skip();
        }
    }
}

After finishing async move { ... }, rendering is performed and async move { ... } is started again.

@fosskers
Copy link
Collaborator

orders.msg_sender() is for passing into other async functions so that you can communicate back to the Seed Event Loop. Otherwise it's morally and behaviourally identical to perform_cmd.

What exactly happened that defied your expectation?

@wkordalski
Copy link
Author

What exactly happened that defied your expectation?

I had a future fut of type impl Future<Output = ()>. After running future fut (performed by orders.perform_cmd(fut)), rendering is triggered, although no message was sent and there is no mention about such behavior in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants