Ed

Any async operation has states: idle, loading, success, or error. Managing these states properly is crucial for good UX. Let's build a state machine!

Your Task:

  • Create a createAsyncState() factory
  • It should track: status (idle/loading/success/error), data, error
  • Methods: startLoading(), setSuccess(data), setError(error), reset()
  • Create getState() to return current state object
TypeScript Solution
Loading...

Submit your code to see test results