https://github.com/ziflex/disposable-decorator
Wraps all custom type methods for checking whether an instance of the type is disposed
https://github.com/ziflex/disposable-decorator
Last synced: 3 months ago
JSON representation
Wraps all custom type methods for checking whether an instance of the type is disposed
- Host: GitHub
- URL: https://github.com/ziflex/disposable-decorator
- Owner: ziflex
- License: mit
- Created: 2016-10-31T20:19:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-07T05:43:17.000Z (over 8 years ago)
- Last Synced: 2025-02-23T15:06:11.656Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# disposable-decorator
Wraps all custom type methods for checking whether an instance of the type is disposed.
[](https://www.npmjs.com/package/disposable-decorator)
[](http://travis-ci.org/ziflex/disposable-decorator)
[](https://coveralls.io/github/ziflex/disposable-decorator)````sh
npm install --save disposable-decorator
````## Usage
````javascript
import composeClass from 'compose-class';
import DisposableMixin from 'disposable-mixin';
import disposableDecorator from 'disposable-decorator';const Person = composeClass({
mixins: [
DisposableMixin()
],decorators: [
disposableDecorator
],constructor(name) {
this._name = name;
},getName() {
return this._name;
},setName(name) {
this._name = name;
}
});const instance = new Person('Mike Wazowski');
console.log(instance.getName()); // 'Mike Wazowski'
instance.dispose();
console.log(instance.getName()); // error 'Object is disposed'
````