Runtime

fx

Small explicit effect type used for systems and runtime orchestration.

Fx models delayed computation with typed success, failure, and environment channels, but stays intentionally minimal instead of becoming a full effect system.

In this library it mainly exists so systems can return executable work while still carrying typed service requirements and explicit failure channels where needed. Most game systems will use Fx.sync(...), but the type keeps the orchestration model uniform.

Examples

// Build one small delayed computation.
const program = Fx.map(Fx.succeed(1), (value) => value + 1)

// Execute it explicitly at the runtime boundary.
const result = Fx.runSync(program)

Functions

Minimal constructors and combinators for explicit delayed computations.

succeed

Source

Creates an effect that immediately succeeds with a value.

Use this for pure values that should still participate in the typed effect composition model.

sync

Source

Wraps a synchronous computation in an Fx.

This is the most common constructor for system implementations in the current runtime because systems are executed synchronously.

fail

Source

Creates an effect that fails by throwing the provided error when run.

map

Source

Transforms the success value of an effect.

flatMap

Source

Sequences two effects, allowing the second one to depend on the first result.

access

Source

Reads the whole effect environment.

Use this when a system helper wants access to all declared services at once.

accessService

Source

Reads a single service from the environment by key.

This is useful for small helpers that need one dependency without threading the entire environment type manually.

provide

Source

Supplies the environment needed by an effect.

runSync

Source

Runs an effect that no longer requires any environment.

The runtime uses this at the edge after it has provided the services declared by a system spec.