Mixin library with full typescript/intellisense support for the Simtopy project
- JavaScript 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .gitignore | ||
| .gitlab-ci.yml | ||
| index.js | ||
| jsconfig.json | ||
| mix.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| test.js | ||
| tsconfig.json | ||
mix
Typed mixin framework for Simtopy libs.
Based on https://github.com/justinfagnani/mixwith.js
Usage
import mix, { Mixin } from "@simtopy/mix"
Declare mixins components
const aMixin = Mixin((superclass) => class A extends superclass {
constructor(key, ...args) {
super(key, ...args)
}
get a() {
return "a"
}
})
const bMixin = Mixin((superclass) => class B extends superclass {
constructor(key, ...args) {
super(key, ...args)
}
get b() {
return "b"
}
})
const cMixin = Mixin((superclass) => class C extends superclass {
constructor(key, ...args) {
super(key, ...args)
}
get c() {
return "c"
}
})
Declare mixin class
class Toto extends mix(aMixin).and(bMixin).and(cMixin).returns() {}
Enjoy !
Instance of toto have all methods and attributes of the mixins, besides, they are recognized and correctly typed by intellisense.
Instanceof operator works has well.