Function createEvent

  • Utility function to generate event creators with specific type

    Returns

    an event creator with the form of (payload: T) => { type: string; payload: T } NOTE: type will be attached to event creator to give access to it from function as property

    Example

    import { createEvent } from "reactive-actor";

    // without payload
    export const startLoader = createEvent('START_LOADER');

    // with payload
    export const getUser = createEvent<{ name: string }>('GET_USER');

    Type Parameters

    Parameters

    • type: string

      event identifier

    Returns EventCreator<T, SM>

Generated using TypeDoc