Do you want mixin syntax in JS, and if so, which semantics? In the prototype chain means super works.
-
-
Already possible - decorators accomplish this wonderfully.
-
Should we have a stdlib decorator for mixins?
-
If a stlib decorator, we need the information/conventions that denote the augmentation so can be handled in something like
@typescriptlang -
I was waiting until later to pull out the TS card ;)
-
Decorators don't have much to do w/ mixins. You can't super from your class into a mixin with a decorator (w/o mucking with the proto chain)
-
What's already possible is the class mixin pattern: let Mixin = (base) => class extends base { ... } class C extends Mixin(S) { ... }
-
Sure, but ergonomics of
@mixin class Base { is much nicer. Also usually don't need to super from class into mixin - code smell imo -
super calls are a fundamental composition primitive, they're critical for mixins to support.
- 8 more replies
New conversation -
-
-
IMHO mixins belong to a different object oriented paradigm
-
Say more.
-
In JS there is a bit different model of OOP than in, for example, Java where it can be useful to have methods which apply only to >
-
> the data of certain class. In JS there are no private and public properties. So I think it’s better to create object with functions >
-
> similar to Math object and leverage functional paradigm.
-
Both private and public fields are almost finalized for a future version of JS :)
-
Almost :( but they are at least at the moment a foreign element :) and I am not sure if formalization is a good thing
End of conversation
New conversation -
-
-
... Assuming you mean mixin to be abstracting common functionality across components or classes.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Actually, both.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Higher order components are more testable for reusing state logic.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.