Skip to content

Commit

Permalink
Add explanation about composeStepRunners
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Jul 28, 2022
1 parent 81e297e commit bb37491
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions code/lib/store/src/csf/stepRunners.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import { AnyFramework, StepRunner } from '@storybook/csf';

/**
* Compose step runners to create a single step runner that applies each step runner in order.
*
* A step runner is a a function that takes a defined step: `step('label', () => { ... })`
* and runs it. The prototypical example is from `@storybook/addon-interactions` where the
* step runner will decorate all instrumented code inside the step with information about the
* label.
*
* In theory it is possible to have more than one addon that wants to run steps; they can be
* composed together in a similar fashion to decorators. In some ways step runners are like
* decorators except it is not intended that they change the context or the play function.
*
* The basic implementation of a step runner is `async (label, play, context) => play(context)`
* -- in fact this is what `composeStepRunners([])` will do.
*
* @param stepRunners an array of StepRunner
* @returns a StepRunner that is the composition of the arguments
*/
export function composeStepRunners<TFramework extends AnyFramework>(
stepRunners: StepRunner<TFramework>[]
): StepRunner<TFramework> {
Expand Down

0 comments on commit bb37491

Please sign in to comment.