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
Re-render in async callback #911
Comments
Hey @Kelerchian thanks for the question! This is already possible :) The Yew way of calling The key point is that |
Sorry didn't mean to close, let me know if this helps :) |
Many thanks, @jstarry. That explains the stuff and reminds me that yew's and react's paradigm and technical challenge are not exactly the same. I'm gonna close the issue. I'm curious, though, is this design intended or caused by some technical difficulties (like mutable reference are only allowed in certain lifecycles)? Also, I just saw there is this issue #314 and I thought yew will need the type of message React is telling to its user https://reactjs.org/docs/thinking-in-react.html Notes on elm/redux-like reducer pattern: But messaging is important for inter-component communication, so this send_message param is a actually a very helpful thing. |
Design is intended. Denis originally designed Yew such that each component acts as its own actor and updates only on messages to keep logic (hopefully) straightforward.
Totally agree. We do have https://yew.rs but it still needs some work
Interesting, kinda like RPC style? I think the messaging naming goes well with the actor design but I can definitely see where you're coming from!
This could work. We would need Yew to debounce the render requests. Could you expand on why you think a method call would be better than the current approach? One thing that's nice about the return is that it limits the update call to only calling render at most one time. |
Only for in-component interactions. For example: The reason is that it's unintuitive to 'send message to self' to trigger some rerender. It'll also be manageable since function call are encouraged to only be used as For inter-component interactions, Current, way is the way. C# event/observable syntax is nice too but it seems to be easier to do in rust. Syntax wise it's shouldn't necessarily the same.
Ah I see that debounce might make things comples.
3.) I always had difficulties navigating between files in redux just to understand the business logic, that's where the "prefer-not-to" attitude came from, lol. (But actually redux's flaw is not the message pattern but it's tendency to drive more junior devs to write god object) But I don't know yet about any technical challenges that you guys might face just to allow this kind of programming pattern. I wish I know more what's under yew's hood and help with it. I think I'll be skimming through the examples to understand more of yew. |
Hi @deniskolodin
I saw this issue #364 and I thought:
Is there any plan to create async callback which in it, component view() can be triggered multiple time
This is similar to what we can do in the js world and it'll be an interesting addition to yew
Btw, I'm new to requesting features in OSS projects so let me know if it's not the good way to go
Cheers
The text was updated successfully, but these errors were encountered: