Class Saga<AR, A>

Saga is a datatype that represents the central point of control deciding what to execute next A. It is responsible for mapping different events from aggregates into action results AR that the Saga then can use to calculate the next actions A to be mapped to command of other aggregates.

Example

const saga: Saga<OddNumberEvt, EvenNumberCmd> = new Saga<OddNumberEvt, EvenNumberCmd>(
(ar) => {
if (ar instanceof OddNumberAddedEvt) {
return [new AddEvenNumberCmd(ar.value + 1)];
} else if (ar instanceof OddNumberMultipliedEvt) {
return [new MultiplyEvenNumberCmd(ar.value + 1)];
} else {
const _: never = e;
console.log('Never just happened in react function: ' + _);
return [];
}
});

Author

Иван Дугалић / Ivan Dugalic /

Idugalic

Type Parameters

  • AR

    Action Result type

  • A

    Action type

Implements

Constructors

  • Type Parameters

    • AR

    • A

    Parameters

    • react: ((ar) => readonly A[])

      A function/lambda that takes input state of type AR, and returns the list of actions A[]>.

        • (ar): readonly A[]
        • Parameters

          • ar: AR

          Returns readonly A[]

    Returns Saga<AR, A>

Properties

react: ((ar) => readonly A[])

Type declaration

    • (ar): readonly A[]
    • A function/lambda that takes input state of type AR, and returns the list of actions A[]>.

      Parameters

      • ar: AR

      Returns readonly A[]

Methods

  • Combines two choreography sagas into one orchestrating Saga

    Type Parameters

    • AR2

    • A2

    Parameters

    • y: Saga<AR2, A2>

      second Saga

    Returns Saga<AR | AR2, A | A2>

  • Left map on AR/ActionResult parameter - Contravariant

    Type Parameters

    • ARn

      New Action Result

    Parameters

    • f: ((arn) => AR)
        • (arn): AR
        • Parameters

          • arn: ARn

          Returns AR

    Returns Saga<ARn, A>

  • Right map on A/Action parameter - Covariant

    Type Parameters

    • An

      New Action

    Parameters

    • f: ((a) => An)
        • (a): An
        • Parameters

          • a: A

          Returns An

    Returns Saga<AR, An>

Generated using TypeDoc