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
{{ message }}
Repository navigation
[labs/observers] ResizeController "observe" is available publicly, but "unobserve" is not. #3237
You can currently ResizeController.observe(...) new elements across the lifecycle of the controller, but you aren't given API to unobserve those elements. This method should likely be made private so that it is less likely to lead someone to leverage it and some sort of setter for the target (hopefully one that is easier to use than at current and accepts an array of elements) should be surfaced to ensure that more content can be easily managed by the observer.
This seems like a common patterns in the observer controllers, so each might benefit the same API structure.
Happy to mark up a PR for this if it's acceptable.
Alternatives and Workarounds
WORKAROUND:
You can force the type today with:
(this.resizeController as unknown as {
_observer: ResizeObserver
})._observer.unobserve(item);
ALTERANATIVE 1:
Or the observe method could be made private to clarify that this isn't functionality that should be taken advantage of outside of the host and target arguments in the constructor.
Reacted by Maga D. Zandaqo, Justin Fagnani and Hunter Loftis
Since ResizeObserver has an unobserve() method, it makes sense for the controller to also, for symmetry. I'd maybe be in favor of removing observe(), but that's a different discussion.
Activity
justinfagnani commentedon Sep 1, 2022
Since ResizeObserver has an
unobserve()method, it makes sense for the controller to also, for symmetry. I'd maybe be in favor of removingobserve(), but that's a different discussion.This is a great issue for a contributino!
[labs/observers] Add unobserve method to ResizeController and Interse…
Update rethink scroll to (#3482)