We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
将debounce返回的函数赋值到methods中,执行的时候,传入的函数的this为 undefined
The text was updated successfully, but these errors were encountered:
Is there a solution?
Sorry, something went wrong.
Two options:
.bind()
class Player { constructor() { // Option 1 this.defend = debounce({ delay: 100 }, this.defend.bind(this)) } defend() { this.game.apply(new DefendAction(this)) } // Option 2 attack = debounce({ delay: 100 }, () => { this.game.apply(new AttackAction(this)) }) }
P.S. Give the Radashi fork a try. It's an actively maintained and improved version of Radash.
No branches or pull requests
将debounce返回的函数赋值到methods中,执行的时候,传入的函数的this为 undefined
The text was updated successfully, but these errors were encountered: