5 releases (breaking)

0.5.0 Mar 10, 2026
0.4.0 Dec 8, 2025
0.3.0 Sep 29, 2023
0.2.0 Nov 28, 2022
0.1.0 Dec 11, 2021

#1816 in Web programming

Download history 1069/week @ 2026-02-19 1009/week @ 2026-02-26 1931/week @ 2026-03-05 1645/week @ 2026-03-12 2009/week @ 2026-03-19 2921/week @ 2026-03-26 2134/week @ 2026-04-02 2484/week @ 2026-04-09 2436/week @ 2026-04-16 1644/week @ 2026-04-23 2205/week @ 2026-04-30 3511/week @ 2026-05-07 5289/week @ 2026-05-14 4258/week @ 2026-05-21 4756/week @ 2026-05-28 3200/week @ 2026-06-04

18,225 downloads per month
Used in 6 crates (4 directly)

MIT/Apache

720KB
17K SLoC

Yew Agent

This module contains Yew's web worker implementation.

Types

There're a couple kinds of agents:

Oneshot

A kind of agent that for each input, a single output is returned.

Reactor

A kind of agent that can send many inputs and receive many outputs over a single bridge.

Worker

The low-level implementation of agents that provides an actor model and communicates with multiple bridges.

Reachability

When an agent is spawned, each agent is associated with a reachability.

Private

Each time a bridge is created, a new instance of agent is spawned. This allows parallel computing between agents.

Public

Public agents are shared among all children of a provider. Only 1 instance will be spawned for each public agents provider.

Provider

Each Agent requires a provider to provide communications and maintain bridges. All hooks must be called within a provider.

Communications with Agents

Hooks provides means to communicate with agent instances.

Bridge

See: use_worker_bridge, use_reactor_bridge

A bridge takes a callback to receive outputs from agents and provides a handle to send inputs to agents.

Subscription

See: use_worker_subscription, use_reactor_subscription

Similar to bridges, a subscription produces a handle to send inputs to agents. However, instead of notifying the receiver with a callback, it collect all outputs into a slice.

Runner

See: use_oneshot_runner

Unlike other agents, oneshot bridges provide a use_oneshot_runner hook to execute oneshot agents on demand.

Dependencies

~14–20MB
~291K SLoC