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

omit where expectation is the same #51

Closed
wants to merge 1 commit into
base: beta
from

Conversation

Projects
None yet
3 participants
@tanner0101
Copy link
Contributor

tanner0101 commented Jan 22, 2018

This allows for omitting the to: label (in an ambiguous-safe way) by limiting it to returns of the same expectation. This helps to cut down on unnecessary noise.

return asyncThing1().flatMap(to: Void.self) {
    return asyncThing1()
}.flatMap(to: Void.self) {
    return asyncThing1()
}.flatMap(to: Bool.self) {
    return asyncThing2()
}.flatMap(to: Bool.self) {
    return asyncThing2()
}

Becomes:

return asyncThing1().flatMap {
    return asyncThing1()
}.flatMap {
    return asyncThing1()
}.flatMap(to: Bool.self) {
    return asyncThing2()
}.flatMap {
    return asyncThing2()
}

@tanner0101 tanner0101 added this to the 1.0 milestone Jan 22, 2018

@tanner0101 tanner0101 self-assigned this Jan 22, 2018

@tanner0101 tanner0101 requested a review from Joannis Jan 22, 2018

@tanner0101 tanner0101 referenced this pull request Jan 22, 2018

Open

rw cache beta #1

@Joannis
Copy link
Contributor

Joannis left a comment

Won't this make the existing map and flatMap APIs confusing?

@tanner0101

This comment has been minimized.

Copy link
Contributor Author

tanner0101 commented Feb 9, 2018

return req.content.decode(User.self).flatMap { user in
    return user.save(on: req)
}

@tanner0101 tanner0101 added this to Todo in Vapor 3 Feb 12, 2018

@rafiki270

This comment has been minimized.

Copy link

rafiki270 commented Feb 13, 2018

I agree with @Joannis it would make the current stuff confusing but still think there might be a solution to get this in like not calling the method .map at all ... maybe .modify as you modifying the result of the future?

@tanner0101 tanner0101 closed this Feb 23, 2018

@tanner0101

This comment has been minimized.

Copy link
Contributor Author

tanner0101 commented Feb 23, 2018

Closing since it seems unpopular. Counter argument is that the inconsistency will confuse newcomers.

@tanner0101 tanner0101 removed this from Todo in Vapor 3 Mar 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment