Re: [WICG/webcomponents] The MountObserver api, an alternative lazy custom element definition proposal (#896)

I love this proposal. 

Potentially dumb question. 

Why not just have the `on` property take either a selector string, or a plain function that returns a boolean? For all the other use cases like media query, instanceof and the like could be static methods on the `MountObserver` class if really needed. like so:

```js 
const observer = new MountObserver({
   on: MountObserver.whereInstanceOf(MyCustomElement),
   import: './my-element.js',
   do: {
      mount: ({localName}, {module}) => {
      // ....
      }
   }
});
observer.observe(document);

```

Also, why have a specific `import` property, when that could be handled by the mount function? 


Thanks.


-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/896#issuecomment-2070234767
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/896/2070234767@github.com>

Received on Monday, 22 April 2024 16:58:44 UTC