Closed s-cork closed 1 year ago
We currently can't use anvil.server.call from inside a web worker, (it doesn't exist)
but if we can fix #100 Then we can create a poor man's anvil.server.call implementation, which will look something like
anvil.server.call
from anvil.js.window import fetch def call(fn_name, *args, **kws): rv = fetch(get_api_origin() + f"/anvil_labs_private_call?name={fn_name}", { "method": "POST", "body": serialize(args, kws) }) if rv.error: raise reconstruct(rv.error) else: return rv.result # in anvil_labs server modul @anvil.server.http_endpoint("/anvil_labs_private_call") def anvil_labs_private_call(name): args, kws = deserialize(anvil.server.request.body) rv = {"result": None, "error": None} try: rv["result"] = anvil.server.call(name, *args, **kws) except Exceptions as e: rv["error"] = serialize_error(e) return rv
We'd have to be careful about cors stuff, but it might be alright since the app origin would be the same Serialization might be a pain.
If we want to really go for it we could adapt kompot for the purpose! And then maybe everything would just... work?
We currently can't use anvil.server.call from inside a web worker, (it doesn't exist)
but if we can fix #100 Then we can create a poor man's
anvil.server.call
implementation, which will look something likeWe'd have to be careful about cors stuff, but it might be alright since the app origin would be the same Serialization might be a pain.
If we want to really go for it we could adapt kompot for the purpose! And then maybe everything would just... work?