Skip to content

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

Description

@wkordalski

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions