@biorate/run-context
v1.64.0
Published
Contexted scenarios execution by Middleware-based template
Downloads
4
Readme
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
Copyright (c) 2021-present Leonid Levkin (llevkin)