class SagaInstance

The data for a single execution of a Saga

Sagas are stateful concepts, and this type contains the state.

Properties

internalData

Signature
readonly internalData: any;

record

Signature
readonly record?: Record;

timersToAdd

Private instance data

Signature
readonly timersToAdd: {
        name: TimeoutNames;
        config: {
            isCron: true;
            crontab: string;
        } | {
            isCron: false;
            timeout: number;
        };
    }[];

timersToRemove

Private instance data

Signature
readonly timersToRemove: TimeoutNames[];

Constructors

(constructor)(internalData, record)

Constructs a new instance of the SagaInstance class

Parameters
Name Type Description

internalData

any

record

Record

Signature
constructor(internalData: any, record?: Record);

Methods

endSaga(preserveInstanceData)

Parameters
Name Type Description

preserveInstanceData

boolean

Returns

void

Signature
endSaga(preserveInstanceData?: boolean): void;

get(name)

Get a piece of arbitrary data from the saga instance

Parameters
Name Type Description

name

K

THe key

Returns

T[K]

Signature
get<K extends keyof T>(name: K): T[K];

lastEvent()

Signature
lastEvent(): EventicleEvent;

removeTimer(name)

Parameters
Name Type Description

name

TimeoutNames

Returns

void

Signature
removeTimer(name: TimeoutNames): void;

set(name, value)

Set a piece of arbitrary data into the saga instance

Parameters
Name Type Description

name

keyof T

The key

value

any

the value. Must be able to encode to JSON.

Returns

void

Signature
set(name: keyof T, value: any): void;

upsertTimer(name, config)

Create (or overwrite) a timer to call. Can be either a simple timer (millis to wait), or a cron timer.

If the timer is no longer wanted, it must be removed by calling

Parameters
Name Type Description

name

TimeoutNames

The timer to call

config

{ isCron: true; crontab: string; } | { isCron: false; timeout: number; }

Returns

void

Signature
upsertTimer(name: TimeoutNames, config: {
        isCron: true;
        crontab: string;
    } | {
        isCron: false;
        timeout: number;
    }): void;