TransactionParser - v0.3.1
    Preparing search index...

    Class TypedEventEmitter<IEvent>

    The TypedEventEmitter class is used to provide a typed way of emitting events.

    It can be used by a consumer application to be notified during certain stages while executing this package, for example when parsing a copybook, an event is triggered at the start of parsing, at the start of every new line, at the end of every line and at the end of processing.


    • IParsingEvent defines the start, newLine, endLine and end event that are triggered during copybook parsing
    • ITransactionPackageEvent defines the parsingComplete, transactionsLoaded, transactionCreated and transactionPackageSaved event that are triggered by certain actions within this class

    Subscribe to events

    const parser = new CopybookParser('/path/to/copybook');
    const emitter = parser.getEventEmitter()
    emitter.subscribe('start', (payload) => {
    console.log(payload) // contains properties copybook, rawData and preparedData
    });

    Emitting events

    const emitter = new TypedEventEmitter<IParsingEvent>(); // start, newLine, endLine and end events will be available
    emitter.emit('start', { copybook: '/path/to/copybook', rawData: ' rawData ', preparedData: ['rawData']})

    Type Parameters

    • IEvent
    Index

    Constructors

    Methods

    • Emit event event of type K to all subscribers

      Type Parameters

      • K extends string | number | symbol

        Interface defining the events

      Parameters

      • event: K

        Type of event to emit

      • payload: IEvent[K]

        Data that will be provided to the subscribers

      Returns void

    • Subscribe to an event of type K only once.

      After the event has been emitted, an unsubscribe for event of type K will be done

      Type Parameters

      • K extends string | number | symbol

        Interface defining the events

      Parameters

      • event: K

        Type of event to subscribe to

      • callback: EventCallback<IEvent[K]>

        Callback to execute when event is triggered

      Returns void

    • Subscribe to an event of type K

      Type Parameters

      • K extends string | number | symbol

        Interface defining the events

      Parameters

      • event: K

        Type of event to subscribe to

      • callback: EventCallback<IEvent[K]>

        Callback to execute when event is triggered

      Returns void

    • Unsubscribe to an event of type K

      Type Parameters

      • K extends string | number | symbol

        Interface defining the events

      Parameters

      • event: K

        Type of event to unsubscribe for

      • callback: EventCallback<IEvent[K]>

        Callback that will be unsubscribed

      Returns void