Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change state to be a tagged-union like type
By turning state from simple string literals to full objects, we can add annotations that are specific to one state. Use case: When retrying connections, we could just add a connectionAttempt?: number; property, but then we would have to check if it is undefined or not, and if we are not reconnecting currently and connectionAttempt? is set, does that mean the Sarus client entered an invalid state? By guaranteeing certain properties to only ever be present when the state property has the right kind, we can avoid a whole class of bugs just by relying on the type system.
- Loading branch information