-
Notifications
You must be signed in to change notification settings - Fork 73
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
[NOT A BUG] How to pass sharedValue to custom parser worklet #611
Comments
Found a solution myself, have to put |
Hi @OzymandiasTheGreat, no worries, thanks for the questions. We're working on something similar with @289Adam289 and we have noticed similar problems.
Exactly that. runOnUI(() => {
'worklet';
sv.value = 42;
})(); So if you want to update a shared value and then read it on the Markdown worklet runtime, you need to call runOnRuntime(getMarkdownRuntime(), () => {
'worklet';
sv.value = 42;
})(); or even better runOnRuntime(getMarkdownRuntime(), (newValue) => {
'worklet';
sv.value = newValue;
})(42); which re-uses the same worklet and serializes only FYI,
Exactly, changing Ultimately, we'd like to reformat As for workaround, what works for us is to regenerate function unregisterParser(parserId: number) {
setTimeout(() => {
global.jsi_unregisterMarkdownWorklet(parserId);
}, 1000);
} I understand this is not an ideal fix so we'll investigate further. |
Thank you very much, that was a very detailed explanation. I have a vague idea of how this all ties together now. Regenerating parser worklet rather than key is both kinda dumb and kinda genius, I'll try it later as I see 0.1.228 is not on npm yet. |
@OzymandiasTheGreat No worries, thanks for asking.
Oops, looks like the workflow failed, I'll ask around to see how we can fix that. |
@OzymandiasTheGreat FYI, 0.1.230 is out on npm. |
First let me apologize for posting a question, I don't see that you have discussions enabled.
Also this might be reanimated question, I don't have much experience with either, so I'm not sure.
I'm trying to build a rich text editor based on live markdown, but using custom parser that depends on external state rather than parsing input on every render. To do this I store the external state in a sharedValue that I update from js and expect to see the changed values in parser worklet.
However this doesn't seem to work. No matter what I do the sharedValue.value returns initial value.
Doesn't matter if I access it on js thread (expected, since it's async) or UI (or whatever thread parser runs on) thread.
I'm putting my code below, maybe you can tell me what I'm doing wrong.
The text was updated successfully, but these errors were encountered: