Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different api for delay setting #16

Open
twhitbeck opened this issue Dec 16, 2021 · 0 comments
Open

Different api for delay setting #16

twhitbeck opened this issue Dec 16, 2021 · 0 comments

Comments

@twhitbeck
Copy link
Contributor

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()), ...))
    )
  }
/>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant