-
Notifications
You must be signed in to change notification settings - Fork 8
Compose
James edited this page Jun 24, 2017
·
2 revisions
use features as needed
const DefaultExt = [Observe, Shorthands, Transform, DotProp]
const Target = class {}
type Exts = Class[] | undefined
// any composable have a .compose method to re-compose them
// default they extend an empty base class
interface Composable extends Class {
compose: Composer
}
function compose(target?: Class = Target, extensions?: Exts = DefaultExt): Composable
const {compose} = require('chain-able')
// uses default params
class Eh extends compose() {}
const {compose} = require('chain-able')
const {Observe} = compose
class Canada {}
const Composed = compose(Canada, [Observe])
class Eh extends Composed {}
const {compose} = require('chain-able')
const {Observe} = compose
class Canada {}
const Composed = compose(Canada, [Observe])
class Eh extends Composed {}
@compose()
class Eh {}
export classes that dynamically extend a base class, similar to how decorators work, but much faster.
❗ they can be used with decorator syntax as well
module.exports = SuperClass => class Eh extends SuperClass {}