API reference > @kontsedal/olas-core > effect
effect() function
Run fn immediately and again whenever any signal it reads changes. Iffn returns a function, that function is called as a cleanup before the next re-run and on dispose.
Returns a dispose function. Inside a controller use ctx.effect(...) instead — that variant is auto-disposed with the controller.
Signature:
typescript
export declare function effect(fn: () => void | (() => void)): () => void;Parameters
Parameter | Type | Description |
|---|---|---|
fn | () => void | (() => void) |
Returns:
() => void