-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add zodern solution for Async stubs #12897
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 zodern solution for Async stubs #12897
Conversation
Fixes 'Error: A method named 'echo' is already defined' on Travis
The queue was causing methods and subscriptions to run out of order. I pushed a commit that also queues subscriptions to maintain the order. Meteor.isAsyncCall is broken. I'm not sure what the purpose of the function is, and how it should behave with the queue.
The tests copied over from the zodern:fix-async-stubs package won't pass until #12888 is fixed. I gave up on supporting Meteor 3 when I found that bug, so I'm not sure if there are any other Meteor 3 specific issues with the code. |
It seems all of the tests are now passing except for the ones copied from zodern:fix-async-stubs (which requires #12888 to be fixed first). |
Hey @zodern! The idea for Meteor.callAsync is to behave what we would expect for an async version of const something = Meteor.callAsync(...);
const resultFromStub = await something; // Or `resultFromServer`, if there's no stub.
const resultFromServer = await something.server; I think we should follow this API design, developers migrating to meteor3 and people starting now can follow it easily. I would like to hear your thoughts @zodern |
I had proposed a similar api here with some differences. I think
Currently, const promise = Meteor.callAsync(...);
const resultFromStub = await promise.stubPromise;
const resultFromServer = await promise;
// backwards compatible with existing code:
const resultFromServer = await Meteor.callAsync(...); |
In your proposal @zodern, if the |
Meteor.callAsync would always return the server promise, with an additional property for the stub promise. I would assume the stub promise would always be defined (and resolve to undefined for methods without a stub) but it doesn't have to work that way. |
Relates to this forum post
Created this PR to test the code against our CI