Is there more "native" way for effector instead of waitForTask?
import { createEffect } from 'effector'
const runTestTask = createEffect({
async handler (name) {
// Simulating long task
await new Promise(resolve => setTimeout(resolve, 10000));
return { name };
}
});
function waitForTask (cb) {
if (runTestTask.pending.getState()) {
const unsub = runTestTask.doneData.watch(() => {
unsub();
cb({ ... });
});
} else {
cb({ ... });
}
}
Yes, Effect itself has four fields .done - an event that's emitted as soon as the handler has been resolved .fail - an event that's emitted as soon as the handler has been rejected .finally - an event that's emitted as soon as the handler has been finished
if we are talking about dataflow the simplest cases will be the following:
OR
I wrote an article to resolve common misunderstandings