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

Side effects (ie network requests) #7

Closed
keeslinp opened this issue Dec 25, 2017 · 3 comments
Closed

Side effects (ie network requests) #7

keeslinp opened this issue Dec 25, 2017 · 3 comments

Comments

@keeslinp
Copy link

I mentioned this briefly in the rustlang thread but maybe that conversation would be better continued here.

I'm playing around with this library and I'm a huge fan so far. I'm interested in contributing and so I started making a simple example site to see where the unimplemented parts are of this library so that I could help out. I noticed that there was no paradigm set up for side-effects or asynchronous code, such as network requests. I was able to perform async code and mutate the model using Rc<RefCell<>> but it would not call the view again until another update triggered a re-render.

Elm handles this scenario using Commands. Is this the same way that you want to solve this problem in yew? Or is there another solution that seems more "rusty"?

@therustmonk
Copy link
Member

Hi! Thank you for the issue! I've merged last changes (#11) where I've implemented Services concept. It works like subscriptions in Elm, but more flexible and handy. In the next few days I will implement Fetch for you. I already have a prototype implementation ;)

Timeout service example: https://github.com/DenisKolodin/yew/blob/master/examples/timer/src/main.rs
How to implement a service: https://github.com/DenisKolodin/yew/blob/master/src/services.rs

@keeslinp
Copy link
Author

Awesome! I'll definitely play around with that. Thanks :). I have an open PR adding network requests to stdweb so if that goes through you could base your fetch request on that (it seems that you are already using stdweb). koute/stdweb#50

@keeslinp
Copy link
Author

I was able to get it working by writing a custom network service that used by branch of stdweb. Once I can get that merged in I'll put up the site that I used as an example. For now I'll close this issue because the problem is resolved.

bors bot pushed a commit that referenced this issue Sep 26, 2019
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