anvilistas / anvil-labs

MIT License
9 stars 3 forks source link

some more non-blocking tweaks #47

Closed s-cork closed 2 years ago

s-cork commented 2 years ago

Bug fix: Because we're using js interop, if an asyn call returns a dictionary - this will get converted to a javascript object and will then be returned as a proxy object. We don't want that so instead wrap the return value in a more opaque python class that won't be subject to the same javascript <-> python dance.

Changes: Raise a RuntimeError if trying to access the result/error from a promise before it has fulfilled. Trying to use the result property before the function has returned is a recipe for disaster. We're not Javascript so we should raise an exception.

Use anvil.js.report_exceptions to wrap the error/result handlers. Currently if the result_handler raises an exception this exception would get passed to the on_error handler. We don't want that. The on_error handler should be exclusively for errors thrown by the function that was called asynchronously.