Table of Contents

Method Subscribe

Namespace
Velvet
Assembly
Velvet.Docs.dll

Subscribe(Action<TState>, bool)

Subscribes to state changes.

public IDisposable Subscribe(Action<TState> listener, bool fireImmediately = false)

Parameters

listener Action<TState>

Invoked on every state mutation. Must not be null.

fireImmediately bool

When true, the listener is invoked synchronously with Current before returning. Default is false — the listener fires only on subsequent state changes.

Returns

IDisposable

Subscribe(Action<TState, TState>, bool)

Subscribes to state changes with a (current, previous) signature.

public IDisposable Subscribe(Action<TState, TState> listener, bool fireImmediately = false)

Parameters

listener Action<TState, TState>

Invoked with (currentState, previousState) on every state mutation. Must not be null.

fireImmediately bool

When true, fires the listener synchronously with (Current, Current) before returning (both arguments equal — there is no previous state at subscribe time). Default is false.

Returns

IDisposable