You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature you'd like
Currently, callbacks made within functional components are annoying to work with. The requirements on callback don't necessarily require 'static, but are pretty much 'static. Note, this means that closures can't contain references to borrowed data, meaning any values used by other state mechanisms need to be cloned into the closure.
However, this wouldn't be necessary if the callbacks could borrow data from other hooks. We can't set the lifetime to be that of the function component itself, but if the data borrowed from the hooks could share the lifetime of the scope, then we could do something along these lines:
From there I imagine we could wrap the hooks in an interface like RefCell that also updates the hook and component.
I'm not 100% sure on where the lifetime would be coming from, since there's no lifetime provided to functional components (instead relying on thread-locals). I imagine we could get a lifetime either when the app is launched (effectively being static) or on the creation of components.
Questionnaire
I'm interested in implementing this myself but don't know where to start
I would like to add this feature
I don't have time to add this right now, but maybe later
The text was updated successfully, but these errors were encountered:
I think the lifetime should be from component being rendered to component being destroyed (re-render would call the hooks again.) I'm not sure if that is possible though.
Describe the feature you'd like
Currently, callbacks made within functional components are annoying to work with. The requirements on callback don't necessarily require
'static
, but are pretty much'static
. Note, this means that closures can't contain references to borrowed data, meaning any values used by other state mechanisms need to be cloned into the closure.However, this wouldn't be necessary if the callbacks could borrow data from other hooks. We can't set the lifetime to be that of the function component itself, but if the data borrowed from the hooks could share the lifetime of the scope, then we could do something along these lines:
From there I imagine we could wrap the hooks in an interface like RefCell that also updates the hook and component.
I'm not 100% sure on where the lifetime would be coming from, since there's no lifetime provided to functional components (instead relying on thread-locals). I imagine we could get a lifetime either when the app is launched (effectively being static) or on the creation of components.
Questionnaire
The text was updated successfully, but these errors were encountered: