Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

mixins #1551

Open
trusktr opened this issue Jan 7, 2019 · 3 comments
Open

mixins #1551

trusktr opened this issue Jan 7, 2019 · 3 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Jan 7, 2019

Feature request

Pleeeease? 馃檹

Use case(s)

Without mixins, Skate has a new issue:

Suppose I import CoolElement from 'cool-element', and CoolElement does not have SkateJS features.

Because SkateJS strictly extends from HTMLElement, I'm stuck, I can not combine Skate features with CoolElement.

If Skate had mixins, then I could write withUpdate(CoolElement), then make a subclass of that to extend it.

@treshugart
Copy link
Member

There's a withProps export from @skatejs/element that you can probably use. I think I'd like to find a better name like withElement.

@trusktr
Copy link
Contributor Author

trusktr commented Mar 2, 2019

Just checked withProps, but all it does is define props and sets attributes on set. I still need to extend from the Component class to get the other stuff withUpdate otherwise had, but now I'll have some other features I don't necessarily need.

I'm still in favor of mixins, and keeping things separate to maximize flexibility:

  • The withProps mixin could be modified to remove attribute handling.
  • A withAttribute mixin could build on it to add attribute reactivity using observedAttributes.
  • Finally, a withUpdate mixin could build on both of those to add life cycle stuff (updating, updated, shouldUpdate, etc)

@treshugart
Copy link
Member

All you should need to do:

  1. Disabled attribute updates by setting { target: false }.
  2. Implement a forceUpdate() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants