Reputation: 664
This is my CoffeeScript code.
setTimeout (-> @checkProgress()), 5000
When I run this in the browser I get the following error:
TypeError: this.checkProgress is not a function
The method looks like:
checkProgress: ->
~ code
~ code
~ code
setTimeout (-> @checkProgress()), 5000
So at some point I want to call the method again. How can I do this? Thanks.
Upvotes: 0
Views: 75
Reputation: 664
This personally worked perfectly for me as well.
recall = =>
@checkProgress()
setTimeout recall, 5000
Upvotes: 0
Reputation: 10680
setTimeout
run @checkProgress
in window
context. Use fat arrow:
setTimeout (() => @checkProgress), 5000
Upvotes: 2