-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
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
Add once to Utils #186
Add once to Utils #186
Conversation
if (ran) { | ||
return result; | ||
} | ||
ran = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this appear after the function has been called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needs to be fixed
Also needs documentation added to the |
updated with usage and documentation. |
no problem at all. updated usage case to have an example of click event. |
// var myHanlder = function () { | ||
// $.ajax({type: 'DELETE', url: 'someurl.com', data: {id: 1}}); | ||
// }; | ||
// this.on('click', utils.once(myHandler)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would add this example to the docs too
Please could you squash your commits too (you can force push to your feature branch and this PR will be automatically updated) |
Squashed |
Great, thanks. Still need to move the |
Oddly enough it actually broke the tests when i changed it. I'm not exactly sure on the reasoning though. I can look into why it wouldn't work. |
describe('once()', function () { | ||
it('should only call a function once', function () { | ||
var sum = 0; | ||
var increment = utils.once(function () { sum++; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/utils/util
Looks like it might have been because you referenced |
@necolas I think its fine as is no? |
@angus-c That seems correct. I can change it to either way. |
add once functionality to utils. Inspired by underscore/lodash.