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

Improve orders explanation #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ebenezerdon
Copy link

Currently, the orders parameter is a bit difficult to understand.
Can you help go through the edit to see if I understood it correctly, myself? If so, I would like to contribute to making it easier for others too.

Currently, the `orders` parameter is a bit difficult to understand. I had to read the section multiple times to get it.
Can you help go through the edit to see if I understood it correctly, myself? If so, I would like to contribute to making it easier for others too.
@MartinKavik
Copy link
Member

Hi @ebenezerdon,

I would recommend to look at some examples like https://github.com/seed-rs/seed/blob/master/examples/subscribe/src/lib.rs or https://github.com/seed-rs/seed/blob/master/examples/fetch/src/simple.rs (just look for orders. in the linked code).

You need to use orders when you want to interact with the App instance (directly or indirectly).
Example: Call orders.subscribe(Msg::UrlChanged) stores a new subscription in the app instance.
Or orders.perform_cmd(...) performs the given command (i.e. spawns the Future on the current thread) and the output message is then pushed to the internal queue in the app instance and then finally passed to your update function.

So orders is basically a way to safely and explicitly perform side-effects in your app. (And it has also some other useful methods to improve developer experience.)

Does it make more sense?

Cheers,
Martin

@ebenezerdon
Copy link
Author

Hi @ebenezerdon,

I would recommend to look at some examples like https://github.com/seed-rs/seed/blob/master/examples/subscribe/src/lib.rs or https://github.com/seed-rs/seed/blob/master/examples/fetch/src/simple.rs (just look for orders. in the linked code).

You need to use orders when you want to interact with the App instance (directly or indirectly).
Example: Call orders.subscribe(Msg::UrlChanged) stores a new subscription in the app instance.
Or orders.perform_cmd(...) performs the given command (i.e. spawns the Future on the current thread) and the output message is then pushed to the internal queue in the app instance and then finally passed to your update function.

So orders is basically a way to safely and explicitly perform side-effects in your app. (And it has also some other useful methods to improve developer experience.)

Does it make more sense?

Cheers,
Martin

Thanks, @MartinKavik. This makes more sense. If you don't mind, I'd appreciate it if the documentation is also updated with the explanation you've provided here. Thanks a lot!

@MartinKavik
Copy link
Member

I'd appreciate it if the documentation is also updated with the explanation you've provided here.

=> reopening to not forget to add it in the future

@MartinKavik MartinKavik reopened this Oct 28, 2020
@MartinKavik MartinKavik added good first issue Good for newcomers help wanted Extra attention is needed labels Oct 28, 2020
@MartinKavik MartinKavik changed the title Reword the explanation for orders parameter Improve orders explanation Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants