Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/izica/debounce-decorator-es6
Debounce decorator for es6+, with promise support
https://github.com/izica/debounce-decorator-es6
debounce debounce-es6 debounce-operator debounced debouncing decoration decorator decorator-transformation decorators es-6 javascript javascript-es6 promise promise-chain
Last synced: 9 days ago
JSON representation
Debounce decorator for es6+, with promise support
- Host: GitHub
- URL: https://github.com/izica/debounce-decorator-es6
- Owner: izica
- Created: 2019-09-19T10:51:36.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-21T17:00:41.000Z (about 5 years ago)
- Last Synced: 2024-10-02T18:10:45.061Z (about 1 month ago)
- Topics: debounce, debounce-es6, debounce-operator, debounced, debouncing, decoration, decorator, decorator-transformation, decorators, es-6, javascript, javascript-es6, promise, promise-chain
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# debounce-decorator-es6
Debounce decorator for es6+, with promise supportsee https://www.npmjs.com/package/decorators-es6
### Install
```
npm install debounce-decorator-es6
```
```
yarn add debounce-decorator-es6
```
### Features
* Easy to use as decorator
* Promise support
* Debounce firing result in Promise chain(.then())### Usage
Default debounce time = 500ms
```javascript
import debounce from 'debounce-decorator-es6';class Store {
message = 'msg';@debounce(1000)
changeMessage = (message) => {
this.message = message;
return 'updated';
};@debounce(1000)
updateOnServer = (message) => {
return axios.post('/message/update', {message});
}
}const store = new Store();
store.changeMessage('msg2');store.changeMessage('msg2').then(value => {
//debounce firing;
console.log(value) // 'updated'
});store.updateOnServer('msg2').then(response => {
//debounce firing;
console.log(response) // axios response from server(Promise resolve)
});```