Module crit.context
Switch between script contexts.
Functions
run_as (msg_id, f) | Schedule a function to run in the context of another script. |
as (msg_id, f) | Wrap a function so that it runs in another script’s context. |
handle (message_id, message_id) | Handle incoming run_as() requests. |
Functions
- run_as (msg_id, f)
-
Schedule a function to run in the context of another script.
For this to work, the script being targeted must call
handle()
in itson_message()
.Parameters:
- msg_id url, hash or string URL to the script in which to run the function.
- f function The function to run in another context.
- as (msg_id, f)
-
Wrap a function so that it runs in another script’s context.
For this to work, the script being targeted must call
handle()
in itson_message()
.Parameters:
- msg_id url, hash or string URL to the script in which to run the function.
- f function The function to run in another context.
Returns:
-
function
The wrapped function. When called, it will schedule
f
to run in the target script’s context. Arguments are passed through tof
, but any return values are lost (sincerun_as()
doesn’t actually call the function synchroneously). - handle (message_id, message_id)
-
Handle incoming
run_as()
requests.For this module to work, you need to call this in
on_message()
in any script that might be targeted byrun_as()
.Parameters: