Skip to main content

IReplayLastSource

Types

interface IReplayLastSourceMethods<GValue> {
getValue(unsafe?: false): GValue;
getValue(unsafe: true): GValue | undefined;
}

type IReplayLastSource<GValue, GSource extends ISource<GValue>> =
Omit<GSource, keyof IReplayLastSourceMethods<GValue>>
& IReplayLastSourceMethods<GValue>;

Definition

A ReplayLastSource is used to store a value and emit it each time we subscribe to it.

This is the perfect candidate if you have to keep the last emitted value.

You can create a IReplayLastSource with the function createReplayLastSource.

This is equivalent to the BehaviorSubject if you provide a MulticastSource.

getValue(...)

Returns the current value stored in this Source.

If the Source is not initialized (no initialValue, or emit(...) called), then, if unsafe is false or undefined, an Error will be thrown, as no value exists. On the contrary, if unsafe is true, undefined will be returned.