-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Fix long standing bug where load* functions could not use callbacks in preload() #956
Conversation
@lmccart This pull request includes unit tests and an example to demonstrate that it works |
hey @Jared-Sprague thanks for this! this definitely fixes the problem, but I feel a little unsure about repeating the same code lines in every function. is there a way to do this in just one place? either somewhere around here where preload is handled, or by making helper methods that get called in each loadX() function? |
@lmccart I don't think there is a way to fix this without modifying each load function, because decrementCallback has to be called inside the load function when in preload, it just used to be called in the place of the success callback. However I totally can extract the common lines from each load function into a helper method. I'll do that now! |
@lmccart Ok check my last commit diff and let me know what you think! |
this looks great. one super nitpicky suggestion, would it make sense to put this above check inside the |
@lmccart sounds fine to me! Stay tuned that will only take a minute. |
@lmccart Ok check it out. Note, I still have to check that (callback !== decrementPreload) because when no callback is passed in decrementPreload will be in the callback position and we don't want to call decrementPreload twice. |
great, thank you! |
Fix long standing bug where load* functions could not use callbacks in preload()
@lmccart whoo hoo! Thank you too! |
Issue: #949
The problem was that the
decrementPreload()
function was getting pushed on the argument list for load functions in_wrapPreload()
and when no success callback was passed to the load functiondecrementCallback()
was assumed to be in the position of the success callback, but when a callback was passed in, decrementPreload would never get called.