Process-local runtime management for the ~JS sigil.
Stores the current Tyrex runtime reference in the process dictionary so
~JS sigils don't need to specify a runtime on every call.
Usage
import Tyrex.Sigil
{:ok, pid} = Tyrex.start()
Tyrex.Inline.set_runtime(pid)
{:ok, 3} = ~JS"1 + 2"Scoped Runtime
Tyrex.Inline.with_runtime(pid, fn ->
{:ok, 3} = ~JS"1 + 2"
end)
Summary
Functions
Evaluate JavaScript code on the current process's runtime.
Get the current Tyrex runtime for this process, or nil if not set.
Set the Tyrex runtime for the current process.
Execute a function with a temporary runtime binding.
Functions
@spec eval(binary(), Keyword.t()) :: {:ok, term()} | {:error, Tyrex.Error.t()}
Evaluate JavaScript code on the current process's runtime.
This is called by the ~JS sigil — you typically don't call it directly.
Get the current Tyrex runtime for this process, or nil if not set.
Set the Tyrex runtime for the current process.
Accepts a PID or a registered name.
Tyrex.Inline.set_runtime(pid)
Tyrex.Inline.set_runtime(MyApp.JS)
Execute a function with a temporary runtime binding.
The previous runtime (if any) is restored after the function returns.
Tyrex.Inline.with_runtime(pid, fn ->
{:ok, 3} = ~JS"1 + 2"
end)