Created
January 26, 2021 19:54
-
-
Save isao/b416013441c688063b8e3cda126e492b to your computer and use it in GitHub Desktop.
`this.args` is undefined in methods wrapped with these decorators.
This file contains hidden or 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
import { debounce as _debounce, throttle as _throttle } from '@ember/runloop'; | |
function timingDecorator(fn) { | |
return function (delay) { | |
return function (instance, property, descriptor) { | |
return { | |
value(...args) { | |
if (!instance.isDestroying && !instance.isDestroyed) { | |
return fn(instance, descriptor.value, ...args, delay); | |
} | |
}, | |
}; | |
}; | |
}; | |
} | |
const debounce = timingDecorator(_debounce); | |
const throttle = timingDecorator(_throttle); | |
export { debounce, throttle }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment