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()), ...))
)
}
/>;
Currently the only way the
delaysetting gets applied is if you usecreateUtils, passing in the sameprefixas you passed when renderingMSWToolbar, and make use of thejsonornotFoundresponse helpers or use thegetDelayfunction yourself when creating your request handlers.This connection feels tenuous. Might an alternative API be:
MSWToolbarreceiving a propworker: SetupWorkerApi | undefineditgetWorker: ((utils): { getDelay: () => number } => Promise<SetupWorkerApi> | SetupWorkerApi) | undefinedThat way it's more obvious how one applies the delay setting to their request handlers.