Commands, services, and jobs
Jobs, services, and commands are reducer-side async tools exposed through ReducerContext::effects. Choose between them based on how long the work needs to live.
Where they live in the runtime model
Reducers update state immediately and explicitly. When a reducer needs outside work, it requests that work through ctx.effects instead of performing it directly.
Jobs, services, and commands are the main APIs for requesting that work.
Jobs
A job runs one unit of async work and returns one result.
Use ctx.effects.app(job, request) for finite app-owned work such as saving a file, loading a document, or scanning a directory once.
Public types in this area include JobSpec, JobRef<J>, and JobCtx.
Jobs are also the normal place to consume large binary streams returned by host capabilities. A reducer should pass a DataStreamId in the typed job request, then the job opens it with JobCtx::open_data_stream(...) and reads the resulting FissionDataStream. Drop the opened stream when processing finishes; this releases its registry entry. SSR/server jobs expose the same stream handle contract through ServerJobCtx.
When work needs to stay alive, emit events, or accept later commands, use a service instead.
Services
A service is long-lived async work that can emit events or receive commands.
Use ctx.effects.start_service(slot, config) for work that stays alive after startup, such as a language server or background sync channel.
Public types in this area include ServiceSpec, ServiceType<Svc>, ServiceSlot<Svc>, ServiceCtx<Svc>, and ServiceBindings.
Services can consume large streams in the same way as jobs through ServiceCtx::open_data_stream(...). Use this when the stream belongs to a long-lived conversation, such as upload progress, import progress, or an editor/language-service workflow that should keep emitting events.
The slot gives the service a stable identity, such as one app-wide service or a separate service for each document.
Commands
A command sends one message to a running service.
Use ctx.effects.command(slot, command) when the service already exists and you want to send it one message, usually expecting a typed success or error response.
Commands do not start services. Start the service first, then send it commands while it is running.
Stopping services
Use ctx.effects.stop_service(slot) when the service lifetime should end explicitly through reducer logic.
Use this for an explicit stop. A service owned by a ServiceResource stops when the runtime removes that resource.
Common callback bindings
The effect builders let you attach typed follow-up actions so the result flows back through ordinary reducers.
For jobs and commands, the common hooks are on_ok(...) and on_err(...).
For service start and service lifetime events, the public bindings include:
The runtime performs the work and returns its result through the same action and reducer model.
How they connect to ReducerContext and ctx.input
When a reducer uses ctx.effects, it is only requesting the work. Later, when the runtime routes results back, reducers can read them from ctx.input.
Reducers read returned payloads through the typed input helpers, then store the
product result or error in app state. The temporary completion envelope stays
in ctx.input; the application does not need a second hidden callback state
store. Include operation identity when a late result could overwrite a newer
edit or the state for another document.
Choose a job when the work is finite.
Choose a service when the work is long-lived and conversational.
Choose a command when you need to send one message to a service that is already alive.
If the work needs identity after its first response, use a service. Otherwise, use a job.
Registration and host setup
Register jobs and services through shell-side with_async(...) configuration at app startup, not inside widgets or reducers.
Related reference pages