Skip to content

[labs/observers] ResizeController "observe" is available publicly, but "unobserve" is not. #3237

@Westbrook

Description

@Westbrook

Should this be an RFC?

  • This is not a substantial change

Which package is this a feature request for?

Observers (@lit-labs/observers)

Description

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.

Metadata

Metadata

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions