Skip to content

Different api for delay setting #16

@twhitbeck

Description

@twhitbeck

Currently the only way the delay setting gets applied is if you use createUtils, passing in the same prefix as you passed when rendering MSWToolbar, and make use of the json or notFound response helpers or use the getDelay function yourself when creating your request handlers.

This connection feels tenuous. Might an alternative API be:

  • rather than MSWToolbar receiving a prop worker: SetupWorkerApi | undefined it
  • receives a getWorker: ((utils): { getDelay: () => number } => Promise<SetupWorkerApi> | SetupWorkerApi) | undefined

That way it's more obvious how one applies the delay setting to their request handlers.

<MSWToolbar
  getWorker={({ getDelay }) =>
    setupWorker(
      rest.get("/foo", (req, res, ctx) => res(ctx.delay(getDelay()), ...))
    )
  }
/>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions