How to use the @boost/event.BailEvent function in @boost/event

To help you get started, we’ve selected a few @boost/event examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github milesj / boost / packages / pipeline / src / WorkUnit.ts View on Github external
index: number = 0;

  output?: Output;

  startTime: number = 0;

  statusText: string = '';

  stopTime: number = 0;

  readonly onFail = new Event<[Error | null]>('fail');

  readonly onPass = new Event<[Output]>('pass');

  readonly onRun = new BailEvent<[Input]>('run');

  readonly onSkip = new Event<[Input]>('skip');

  readonly title: string;

  private action: Action;

  private status: Status = STATUS_PENDING;

  // We want to support all contexts, so we use any.
  // Unknown and `Context` will not work because of the constraint.
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  constructor(title: string, action: Action, options?: Options) {
    super(options);

    if (!title || typeof title !== 'string') {
github milesj / boost / packages / core / src / Task.ts View on Github external
super();

    if (!title || typeof title !== 'string') {
      throw new Error('Tasks require a title.');
    }

    if (action !== null && typeof action !== 'function') {
      throw new Error('Tasks require an executable function.');
    }

    this.action = action;
    this.status = STATUS_PENDING;
    this.title = title;
    this.onFail = new Event('fail');
    this.onPass = new Event('pass');
    this.onRun = new BailEvent('run');
    this.onSkip = new Event('skip');
  }

@boost/event

An event system with multiple emitter patterns.

MIT
Latest version published 7 months ago

Package Health Score

61 / 100
Full package analysis