Support allowing module libraries to provide types for module-written built-in middlewares
Describe the feature
It is currently possible for nuxt modules to add their own custom middleware for users, however, this is not detected by typescript when nuxt 3 generates the types when building/running in dev environment. A workaround could be for the user to add a stub middleware to force nuxt 3 to generate the types as it still seems to be using the middleware defined by the module when running definePageMeta({ middleware: 'customModuleBuiltInThing' }) but it would be great if there could be some option for modules to declare what middleware it's providing so nuxt 3 can generate it.
Related discussion: https://github.com/nuxt/nuxt/discussions/18462
Some use cases:
- Auth middleware: https://github.com/sidebase/nuxt-auth/issues/157
Additional information
- [ ] Would you be willing to help implement this feature?
- [ ] Could this feature be implemented as a module?
Final checks
- [X] Read the contribution guide.
- [X] Check existing discussions and issues.
function alert(){}
map.addLayer({id: 'foo', ... })
map.on('click', 'foo', alert);
map.off('click', 'foo', alert);
map.removeLayer('foo');
If you customize the layer that inherits from CustomLayerInterface , you can turn off all events in onRemove so that all event removal can be done when removeLayer .
map.off('click', 'foo', alert);
Yeah, I know you can do this, but actually managing the handler can be tricky, particularly if it's constructed by some other function.
I can't think of much benefit to the current situation. Would a user ever want/expect a handler to persist, despite removing a layer and adding another with the same id?
I agree. I think it would be reasonable to consider this a bug.
Is there any update on this issue? Am running in to the same situation where we have to manually remove click events, which, for some reason, isn't even working..
Would be great to hear something about this!
@brdv did you ever solve this issue?
@brdv did you ever solve this issue?
Hi Wouter,
I remember the issue being that the mapbox package expected us to pass the exact same function/event (something to do with the location in memory). Since we used React, the function was repeatedly created again, causing the package to see it as a different function/event. We fixed it using the useCallback React hook to create our function/event, which caused the function to stay the 'exact same' each time.
I believe it all has something to do with memory and pointers, but I'm not that experienced with those subject.
I hope this can be of any help to you, good luck!
I hope this can be of any help to you, good luck!
Wow, this solved the issue immediately, thank you so much for your quick reply!
I hope this can be of any help to you, good luck!
Wow, this solved the issue immediately, thank you so much for your quick reply!
Good Day Sir how did you use the useCallback to clear the function inside the event?
oh boy, glad to see this isn't fixed yet.