Handling Incremental States of Effectful Operations in TypeScript

is there a way to incrementally return values from an effect given the status of an effectful operation? ie. if we assume a few states...initializing (no data), loading (no data), complete (with data) and error(with message)? the intent would be to do something like...

handleEffect(effect)({
    Initializing: () => ...,
    Loading: () => ...,
    Success: (data) => ...,
    Failure: (error) => ...,
})


not in front of my pc at the moment but im struggling to get a mental picture of how to incrementally return the state of an effect as i understand effects represent an operation in its entirety making it hard to incrementally return someout outside the context of an effect operation?
Was this page helpful?