Skip to content

wire

wire<I, E, A, S>(source, f): () => void

Defined in: Core/Op.ts:823

Subscribes to a manager and calls a handler when the state reaches OpOk. Returns an unsubscribe function.

I

E

A

S extends State<E, A>

Manager<I, E, A, S>

(a) => void

() => void

const manager = Op.interpret(fetchUser, { strategy: "restartable" });
const stop = Op.wire(manager, (user) => {
  console.log("User loaded:", user.name);
});
manager.run(userId);
// ... later
stop(); // removes the subscription