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

Result initializers are bad. #4

Open
jemmons opened this issue Aug 13, 2018 · 0 comments
Open

Result initializers are bad. #4

jemmons opened this issue Aug 13, 2018 · 0 comments

Comments

@jemmons
Copy link
Owner

jemmons commented Aug 13, 2018

Also, result should probably be move to a different library, but:

Result(MyError.error)

creates a Result<MyError.error> which is probably unexpected. To work properly, the generic type must be explicit:

Result<String>(MyError.error)

We could fix this my making it less of a wrapper and providing argument labels:

Result(error: MyError.error)
Result(value: "thing")

But I also rather like the AlamoFire solution of taking a (throwing) closure:

Result { "hello" } //> Result<String>.success
Result { throw MyError.error; return "hello" } //> Result<String>.failure
jemmons added a commit that referenced this issue Aug 16, 2018
* Adds `asyncFlatMap` for when `transform` has async components.
* Adds `flatRoute` for converting "completion blocks" (AKA "continuations") between result types.
* Adds `asyncFlatRoute` for doing that when the `adaptor` has async components.
* Also deprecates Result initializers. See also: Issue #4.
* Sprinkles in some documentation.
jemmons added a commit that referenced this issue Aug 16, 2018
* Adds `asyncFlatMap` for when `transform` has async components.
* Adds `flatRoute` for converting "completion blocks" (AKA "continuations") between result types.
* Adds `asyncFlatRoute` for doing that when the `adaptor` has async components.
* Adds simple `isSuccess` and `isFailure` predicates for avoiding case statements.
* Also deprecates Result initializers. See also: Issue #4.
* Sprinkles in some documentation.
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

1 participant