Skip to content

[labs/observers] Consider some refactoring and add Lit directive #2350

@sorvell

Description

@sorvell

There are a few potential feature and refactoring improvements to consider:

  • We want to add a Lit directive for more ergonomically observing elements. This could be a separate module that provides an observeWith(observer) directive. This approach allows the controllers to be used without loading lit-html, but it's a little unergonomic v. something like ${controller.observe()}. If we do the latter, we'll need to disambiguate between using observe as a directive and imperatively. This could be done by checking if an argument is provided.
  • Refine the types associated with the callback and value. These are currently just marked as unknown but they could be handled with a generic. Working this out with the tests will take a bit of refinement.
  • The 4 observer controllers could share a base class. They are similar but each have some differences which need to be carefully considered. There's definitely an opportunity for more code sharing, however.

Metadata

Metadata

Labels

No labels
No labels

Projects

Status

📋 Triaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions