-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
Why does it reset to the first handler when the array is empty? #2410
Comments
Hi, @nayounsang. Can you please explain what you are trying to achieve here? Do I understand it right that since One way you can get this behavior even now is relying on -const worker = setupWorker(...handlers)'
+const worker = setupWorker()
+worker.use(...handlers) This won't treat I may even argue that this usage is more correct. Initial, or happy path handlers, aren't meant to be removed. They can be replaced as if to say "now I have a different set of happy path handlers", but removing them entirely may lead to unexpected behaviors if you call |
We can treat it as a documentation issue though. I don't mind adding this explanation and a usage example to https://mswjs.io/docs/api/setup-worker/reset-handlers. |
Hi. Thx for comment @kettanaito.
So, I'm thinking of closing the existing (temporary) my PR: #2411 . |
I'll try to document it based on the contents of this issue! |
Scope
Adds a new behavior
Compatibility
Feature description
I understand initializing when the argument is undefined, but I think initializing it even when it is an empty array is excessive.
It seems troublesome for developers to classify each case.
If the argument is dynamic, it may lead to unexpected behavior.
(However, it seems difficult to distinguish this technically. Is there a good way?)
If I can clear the handler, it may be a bit inconvenient, but I think it can be done anyway.
Well, first, let’s create a PR this way. If it's strange, let's discuss another method!
The text was updated successfully, but these errors were encountered: