@biorate/run-context
TypeScript icon, indicating that this package has built-in type declarations

1.64.0 • Public • Published

Run context

Contexted scenarios execution by Middleware-based template

Example:

import { Scenario, Context, step } from '@biorate/run-context';

export class Scenario1 extends Scenario {
  @step()
  protected async step1() {
    this.ctx.set('step1', true);
  }

  @step()
  protected async step2() {
    this.ctx.set('step2', 1);
  }
}

export class Scenario2 extends Scenario {
  @step()
  protected async step3() {
    this.ctx.set('step3', false);
  }
}

(async () => {
  const ctx = await Context.run([Scenario1, Scenario2], { initial: 'value' });
  console.log(ctx.get<boolean>('step1')); // true
  console.log(ctx.get<number>('step2')); // 1
  console.log(ctx.get<boolean>('step3')); // false
  console.log(ctx.get()); // {
  //    'step1': true,
  //    'step2': 1,
  //    'step3': false
  //  }
})();

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT

Copyright (c) 2021-present Leonid Levkin (llevkin)

Readme

Keywords

none

Package Sidebar

Install

npm i @biorate/run-context

Weekly Downloads

1

Version

1.64.0

License

MIT

Unpacked Size

165 kB

Total Files

53

Last publish

Collaborators

  • llevkin