Skip to content

The source.wait() API #197

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/core/src/__tests__/new-gen/wait.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
describe('source.wait()', () => {
// The wait API should be used in async contexts to wait for a pending
// instance before doing some work.
// Sometimes, you need to grab a state from an instance in an event handler
// but you need to test on whether the status is pending and if it is the case
// you will need to subscribe to the instance and then continue the work after
// it resolves.

// This feature addresses this use case where it would give you a promise to
// be used like this:
// async function myFunction() {
// let state = source.wait();
// | state here is either initial, success or error
// }

// Challenges:
// in case of the returned promise related to an ongoing run gets aborted
// we should notify resolve the promise either ways when state changes
it.skip('should wait for a pending source', () => {

});
it.skip('should resolve instantly when not pending', () => {

});
});