Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an equivalent of Promised for Future, without the Failed state #46

Closed
nadako opened this issue Oct 16, 2020 · 5 comments
Closed

Add an equivalent of Promised for Future, without the Failed state #46

nadako opened this issue Oct 16, 2020 · 5 comments

Comments

@nadako
Copy link
Contributor

nadako commented Oct 16, 2020

From the gitter chat:

I wonder if tink_state should/could have a Futuristic (or something) type, which is like Promised but without Failed state, basically an observable for Future rather than Promise.

in our codebase we use Future instead of Promise quite a lot, because in a lot of cases the error case is handled globally and leads to a "something went wrong, reload your game" modal dialog, especially when it comes to backend communication. so there's no error handling on a higher level. now if some model have data initialized like this, it can only have two states: Loading and Done :)

@kevinresol
Copy link
Member

kevinresol commented Nov 26, 2020

How about just:

enum FutureState<T> {
  Loading;
  Ready(value:T);
}

and replace Promised... (though breaking)

@nadako
Copy link
Contributor Author

nadako commented Nov 26, 2020

Would work for me, sounds easy enough to match for promises too: case Ready(Success(blah)) instead of case Done(blah). But yep I bet it's super breaking.

@kevinresol
Copy link
Member

I think we can introduce a define for easier transition

back2dos added a commit that referenced this issue Nov 27, 2020
@back2dos
Copy link
Member

See #53 for a non-breaking attempt.

back2dos added a commit that referenced this issue Nov 27, 2020
@back2dos
Copy link
Member

Ok, I just went with #53

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

No branches or pull requests

3 participants