officially support mutating middleware
See original GitHub issueBecause of #65, specifically lodash.flatten
, compose()
returns a generator based on a copy of the provided array from that point in time. Any changes made to this array subsequently will no longer be reflected in the returned middleware.
Previously, one could mutate the array after calling compose
.
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (11 by maintainers)
Top Results From Across the Web
Mutation & Revalidation - SWR
Mutation & Revalidation. SWR provides the mutate and useSWRMutation APIs for mutating remote data and related cache.
Read more >Modify res without mutating argument - Stack Overflow
Short answer? Yeah, the general rule is to mutate req and res as they go by your middleware. The official guide even suggests...
Read more >Subscriptions - Apollo GraphQL Docs
You can use subscriptions with any of Apollo Server's supported middleware integrations. To do so, you call installSubscriptionHandlers on your ApolloServer ...
Read more >Docs clarification: when are hooks called? · Issue #553 - GitHub
My use case is synchronising the state of some ents to an external service, obviously only if the mutation succeeds.
Read more >Configuring Your Store - Redux
Most apps extend the functionality of their Redux store by adding middleware or store enhancers (note: middleware is common, enhancers are ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jonathanong The problem occurs if you call app.use to add any middleware after you’ve already triggered a call of app.callback, since this.middleware, the argument that is passed to compose is a mutable array.
this would previously work fine as it would reference the now mutated array, but since the flatten changes the semantics by copying at call time of compose with the flatten, anything added to the middleware after the call to compose is effectively ignored.
I would think that even if this wasn’t an envisioned use case, it still seems like a breaking change since it does, even if inadvertently, change the way the module works.
Thanks for all the hard work!
instead of supporting it here, we will add an ability to configure your compose function in koa https://github.com/koajs/koa/issues/1568