From 21f795ccb562cfafff23c82b6ea3f12648a02fa7 Mon Sep 17 00:00:00 2001 From: Mohamed EL AYADI Date: Sun, 4 Feb 2024 20:13:52 +0100 Subject: [PATCH] draft wait api --- .../core/src/__tests__/new-gen/wait.test.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/core/src/__tests__/new-gen/wait.test.ts diff --git a/packages/core/src/__tests__/new-gen/wait.test.ts b/packages/core/src/__tests__/new-gen/wait.test.ts new file mode 100644 index 00000000..bd73b0f7 --- /dev/null +++ b/packages/core/src/__tests__/new-gen/wait.test.ts @@ -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', () => { + + }); +});