Skip to content

Improve sealed class state support#214

Merged
Rosomack merged 6 commits intomainfrom
feature/improve-sealed-class-state-support
Apr 22, 2024
Merged

Improve sealed class state support#214
Rosomack merged 6 commits intomainfrom
feature/improve-sealed-class-state-support

Conversation

@Rosomack
Copy link
Copy Markdown
Contributor

Addresses: #191

This is not going to turn Orbit into a state machine, but it adds some quality-of-life improvements to working with a sealed class state.

The code in the block is only executed if and while the state is of a given type and matches the predicate. Once either of those conditions becomes no longer true after a state update, the block is cancelled.

@Rosomack Rosomack requested a review from mattmook April 12, 2024 13:08
@jadar
Copy link
Copy Markdown

jadar commented Apr 19, 2024

I like the quality of life improvement. I really liked both of the options in #197. I can't help but notice that you didn't go with either of those. Is there a reason for that? I think the reason I prefer the original API options is that I preferred the generic parameter better than passing the actual class.

@Rosomack
Copy link
Copy Markdown
Contributor Author

Rosomack commented Apr 22, 2024

@jadar since the extension function takes 3 type parameters (state, side effect, type to "cast"), you'd have to write <_, _, SomeState.Loading> with the underscored parameters being inherited from the ContainerHost... I found no way around this sadly.

I would have also preferred a single type parameter 💯

This is as close to withSubstate as we can get I think.

That said, I'll keep this in mind and keep trying to simplify

@Rosomack Rosomack merged commit 261212f into main Apr 22, 2024
@Rosomack Rosomack deleted the feature/improve-sealed-class-state-support branch April 22, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants