Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The transformer is defined as an actor and cand be sync as well as async.

Code Block
languagejstypescript
const transformer = {
    name: "transformer_name", 
    eventGrammar: "es11", //EventGrammar on which the transformer can act.
    datasetGrammar: "ds23", //Dataset that this transformer which modify.
    config: {
        spawn((callback, receive) => {

            // manage side effects here 
            // Examples - logging, pushing to an externa event bus, etc.
            callback('SOME_EVENT');

            // receive from parent
            transform((event: Event) => {
              // transform event to dataset; Has access to event and dataset grammars for validation
            });
            
            // for speedups
            transform((event: Event[]) => {
              // transform events to dataset; Has access to event and dataset grammars for validation
            });

            // disposal
            return () => {
              /* do cleanup here */
              /* push this to dataset */
            };
        }),
    }
}

...