-
Notifications
You must be signed in to change notification settings - Fork 109
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
Record.whenReady() has inconsistent behavior #76
Comments
Hi @Vortex375 a record's
|
However, having this inconsistent behavior complicates the usage of this "convenience" method, because you have to check the It also prevents the method from being used conveniently with Most importantly, it is common design practice to have a method either always invoke its callback synchronously or asynchronously - not both. Though the behavior is somewhat documented (it states the callback can be invoked "immediately") it is not what a user would expect the method to do. Would there be any drawback to always invoking the callback asynchronously? |
You wouldn't actually need to wrap the method into setTimeout and async.waterfall works perfectly fine with a mix of synchronous and asynchronous methods. As mentioned, |
Record.whenReady() sometimes invokes the callback synchronously (i.e. "immediately) and sometimes asynchronously by using this.once('ready', ...).
This is known as "releasing Zalgo" (http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
whenReady() should always invoke the callback asynchronously (e.g. using setTimeout()).
The text was updated successfully, but these errors were encountered: