setWorld
Override or reset the cached World instance used by the workflow runtime.
Overrides the cached World instance that getWorld() returns. Use it to inject a World constructed with explicit configuration (rather than environment variables), or pass undefined to clear the cache so the next getWorld() call reinitializes from the current environment.
import { setWorld, getWorld } from "workflow/runtime";
import type { World } from "@workflow/world";
declare const customWorld: World; // @setup
setWorld(customWorld);
const world = await getWorld(); // resolves customWorldAPI signature
Parameters
| Parameter | Type | Description |
|---|---|---|
world | World | undefined | The World instance to use, or undefined to reset the cache and reinitialize from environment variables on next access |
Returns
This function does not return a value.
Example: Reset after environment changes
import { setWorld, getWorld } from "workflow/runtime";
process.env.WORKFLOW_TARGET_WORLD = "@workflow/world-local";
setWorld(undefined); // clear the cached instance
const world = await getWorld(); // reinitialized with new configurationRelated functions
getWorld()- Resolve the cached World instance.createWorld()- Construct a fresh World from environment configuration.