Closed s-cork closed 1 year ago
@s-cork We are using this as a dependency but I will revert to using the code in a standalone module until we have verified everything. Give me 10 Minutes.
@s-cork we are now working off a module and have added the above script in. All good to go from our end - Thank you.
Features:
Import arbitrary app modules from inside the web_worker module
this includes dependencies - i.e.
from anvil_extras import storage
should just work To make it work we needanvil.js
as a module available in the webworker (anvil_extras.storage
uses it). So I create a dummy module since we don't have access to the real anvil.js module I also addanvil.server
as a dummy module since it allows us to callanvil.server.get_api_endpoint()
from within the webworker. (We could extend the anvil.server module to include anvil.server.call - but this might be too cute - it would only mimic the real anvil.sever.call behaviour and would likely fail in unexpected ways)_Breaking change:
Anyone using web workers will need to add:
to their native libraries This script allows us to intercept python source code from the app and save it for later, to be injected into the web worker. This seemed like the best approach since it's not exposed by anvil. (see js/pre-worker/mod.ts)
We could do this later, but later might be too late, so putting it in Native Libraries seemed best.
This approach should help us with background-sync later.
@rhurlbatt - are you using anvil-labs as a dependency? If you are you should add the above script tags before we merge this ❗️⚠️