Understanding and Implementing Fibers and runFork for Event Handling
Trying to understand how to use fibers, runFork, etc correctly …
I have an event handler that invokes a promise that I need the result of and it may block for a long time. When it completes I want to emit an event another event with the result I can handle elsewhere in the program.
First thing I thought to do: Run the handler with runFork, run the long running promise with runFork, then use addObserver on the fiber returned from that, and have its callback emit the exit value.
In tests it looks like the callback to addObserver runs when the initial handler with runPromise. When I use runFork instead (and call .await() on the handler’s fiber) it’s not called.
I have an event handler that invokes a promise that I need the result of and it may block for a long time. When it completes I want to emit an event another event with the result I can handle elsewhere in the program.
First thing I thought to do: Run the handler with runFork, run the long running promise with runFork, then use addObserver on the fiber returned from that, and have its callback emit the exit value.
In tests it looks like the callback to addObserver runs when the initial handler with runPromise. When I use runFork instead (and call .await() on the handler’s fiber) it’s not called.
