You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just realized, out of a one-off example in Discord, that if a worker has listeners added after some reference is created or populated with values, the synchronous dance might mislead because that reference on the main might have been already bootstrapped or triggered/resolved.
The explicit issue I am talking about is this one:
image=window.Image.new()
# if this is before, we're all goodimage.onload=lambdae: document.body.append(image)
# if that is after though, setting an inline source of the image# will resolve it before the next `.onload = ...` or even# `.addEventListener` is attachedimage.src=f'data:image/svg+xml;utf8,{svg}'
I had to double-check why, once added the worker attribute, that would not work.
Due inability to hook into listeners happening on the main, I think it's worth it to document the best way to be sure a listener is triggered, either on main or worker thread, is to define listeners related to such bootstrap AOT (Ahead of Time) and not later.
This is an important detail I could see myself failing at remembering on occasions, so I think it should be part, at least, of our F.A.Q.s section.
The text was updated successfully, but these errors were encountered:
I just realized, out of a one-off example in Discord, that if a worker has listeners added after some reference is created or populated with values, the synchronous dance might mislead because that reference on the main might have been already bootstrapped or triggered/resolved.
The explicit issue I am talking about is this one:
The demo in case is this one https://pyscript.com/@agiammarchi/svg-image/latest?files=main.py,index.html
I had to double-check why, once added the
worker
attribute, that would not work.Due inability to hook into listeners happening on the main, I think it's worth it to document the best way to be sure a listener is triggered, either on main or worker thread, is to define listeners related to such bootstrap AOT (Ahead of Time) and not later.
This is an important detail I could see myself failing at remembering on occasions, so I think it should be part, at least, of our F.A.Q.s section.
The text was updated successfully, but these errors were encountered: