Interface IStateRepository<C, S, V, CM, SM>

State repository interface / fetching and storing the state from/to storage

Author

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

Idugalic

interface IStateRepository<C, S, V, CM, SM> {
    fetch: ((command) => Promise<null | S & V & SM>);
    save: ((state, commandMetadata, version) => Promise<S & V & SM>);
}

Type Parameters

  • C

    Command

  • S

    State

  • V

    Version

  • CM

    Command Metadata

  • SM

    State Metadata

Hierarchy (view full)

Properties

Properties

fetch: ((command) => Promise<null | S & V & SM>)

Fetch state, version and metadata

Type declaration

    • (command): Promise<null | S & V & SM>
    • Parameters

      • command: C & CM

        Command payload of type C with metadata of type CM

      Returns Promise<null | S & V & SM>

Returns

current State/[S], Version/[V] and State Metadata/[SM]

save: ((state, commandMetadata, version) => Promise<S & V & SM>)

Save state (with optimistic locking)

You can update/save the item/state, but only if the version number in the storage has not changed.

Type declaration

    • (state, commandMetadata, version): Promise<S & V & SM>
    • Parameters

      • state: S

        State with Command Metadata of type S & CM

      • commandMetadata: CM

        Command Metadata of the command that initiated the state

      • version: null | V

        The current version of the state

      Returns Promise<S & V & SM>

Returns

newly saved State of type S & V & SM

Generated using TypeDoc