joist-framework / joist

A small (~2kb) library to help with the creation of web components and web component based applications
121 stars 6 forks source link

change decorators to use factory functions #1024

Closed deebloo closed 3 months ago

deebloo commented 3 months ago

I originally tried to stay away from factory functions for decorators, partially this was so that you could use the library without decorators if you liked and it would FEEL a bit nicer. Now that decorators are moving through the standards track I am comfortable moving back to factories. This also provides a ton more flexibility. For example providers can be passed to the @injectable() decorators directly, this also helps with type hints.

This also allows us to move several static attributes to options in the decorator factory.

@element({
  tagName: 'my-element'
})
@injectable({
  providers: []
})
class MyElement extends HTMLElement {}