Updating and rerendering while still running a callback #1975
Unanswered
arrudagates
asked this question in
Q&A
Replies: 3 comments 9 replies
-
Sorry, I need some clarification. Also, your code is not in Yew🙃 |
Beta Was this translation helpful? Give feedback.
4 replies
-
Or another solution actually, anything that allows me to trigger a render
multiple times while still running that function.
…On Fri, Jul 30, 2021 at 9:08 AM mc1098 ***@***.***> wrote:
Oh, so your hoping for changes made to the &mut self.output in the
run_code function to trigger a render to update the output shown on the
web app?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1975 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGXNIUGJ2S2HUUEGTRJGLTT2KI2PANCNFSM5BHR4MYA>
.
--
*Gabriel Facco de Arruda*
+55 (51) 99826-0101
***@***.*** ***@***.***>*
|
Beta Was this translation helpful? Give feedback.
4 replies
-
That sounds good, I will try that tonight, are there any more relevant code
examples besides pub_sub that you could send?
…On Fri, Jul 30, 2021 at 9:29 AM mc1098 ***@***.***> wrote:
Okay, so updating the state inside the component won't change the rendered
html the only thing that can do that is the Component::view method so
this would only occur after your run_code finished and when
Component::update gets true returned it schedules to render the Component
again. This might explain the behaviour you've been seeing - this would
occur in an agent too because nothing is triggered when altering local
state.
A possible solution is to edit the run_code function to include a Sink
that you can send the updates to output on and for the Yew sink you can
make it send an update Msg for each input to the sink. I think this would
require that the run_code work is done in an Agent which runs on it's own
web worker <https://yew.rs/concepts/agents#reaches>. So the Run button
would send a Msg to the Component then the Component would send a message
to the Agent the Agent would then call run_code with a Sink that would
send Component messages for each incremental update and the component
would probably just push the update onto the output string and return true
and trigger the render. The run_code being in it's own web worker means
that it won't hold up the Component from rendering on each update :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1975 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGXNIURRSCGOGIPUNAHJQTT2KLJTANCNFSM5BHR4MYA>
.
--
*Gabriel Facco de Arruda*
+55 (51) 99826-0101
***@***.*** ***@***.***>*
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Ok so for context: I'm writing a programming language, i have everything working and i have a CLI runner, now I want to build a WASM web app for it and it works great, I'm using conditional compile to maintain the same codebase for both interfaces.
And then comes the problem, I have to run my interpreter and before it finishes interpreting everything i need to handle input and output. Just input works fine, because even though the output field in the page only updates after everything finishes running, that's not a problem for output, but input breaks that, because let say this happens:
Then what will happen is:
So visually for the user it's like this happened:
Here is my code (with only the relevant parts):
Edit: Sorry thats not Yew haha, here's yew:
I also tried agents and the exact same thing happened, I believe it has to run in a separate thread but i couldn't find out how to properly do it within Yew.
I appreciate any help :)
Beta Was this translation helpful? Give feedback.
All reactions