Comments (2)
Thanks for the suggestion @StevenLangbroek
My tests for something like this are:
- Is it actually much better than the default language semantics?
- If so, is it worth the cost in cognitive load on users and implementation complexity?
First, I'm not so sure that this:
@callSuper('before')
foo(){
console.log('foo from mixin');
}
Is better than this:
foo(){
super.foo();
console.log('foo from mixin');
}
What problem does it solve? You can forget the decorator add easily as the support call. It's also using nonstandard features.
Even if it were better, simulating the semantics of super would require code that has a cost.
One thing I might be interested in is a mixin transformer that causes every method in as mixin to delegate. Using it would look like this:
const M = DelegatingMixin('before', s => class extends s {});
Would that help?
from mixwith.js.
I'm going to close this as super.method()
is very standard and offers the most flexibility.
from mixwith.js.
Related Issues (20)
- instanceof check with multiple mixins HOT 1
- setup misunderstanding? HOT 1
- ES3 Implementation HOT 12
- Decorator syntax HOT 1
- Possible to use bare classes as mixins? HOT 6
- Alternative implementation (multiple inheritance with branching prototype chain) HOT 10
- Does mixwith detect and cache sub chains? HOT 1
- New mixin base on existing class HOT 3
- instance instanceof mixin? HOT 4
- Current Version Not In NPM? HOT 4
- Unexpected behavior using rollup
- Compiled version uses ES6 syntax (=>) HOT 21
- Thanks for the inspiration!
- error TS2339: Property 'emit' does not exist on type 'MyClass2'. HOT 1
- TypeError: m is not a function, when extending a class that uses mixins HOT 3
- Extending HTMLElement and Babel
- Update npm package HOT 2
- Error if Symbol not defined. HOT 1
- #feature-request typescript version. HOT 2
- How do i import `mix` (ES6) ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mixwith.js.