-
-
Save hiukky/01f22c030cdb610a8855b553c2473ae3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Class = new (...args: any[]) => any; | |
export function DisposableMixin<Base extends Class>(base: Base) { | |
return class extends base { | |
isDisposed: boolean = false; | |
dispose() { | |
this.isDisposed = true; | |
} | |
}; | |
} | |
export function ActivatableMixin<Base extends Class>(base: Base) { | |
return class extends base { | |
isActive: boolean = false; | |
activate() { | |
this.isActive = true; | |
} | |
deactivate() { | |
this.isActive = false; | |
} | |
}; | |
} | |
class Example extends DisposableMixin(ActivatableMixin(class { })) { | |
member = 123; | |
constructor() { | |
super(); | |
} | |
} | |
const example: Example = new Example(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment