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

New Observable value syntax (especially with Optionals) #4

Open
slazyk opened this issue Aug 19, 2014 · 0 comments
Open

New Observable value syntax (especially with Optionals) #4

slazyk opened this issue Aug 19, 2014 · 0 comments

Comments

@slazyk
Copy link
Owner

slazyk commented Aug 19, 2014

As originally described in the answer to #2, now that there is no possibility to define implicit conversions from Observable<T> to T, preferred way of getting the value out of the optional is via a postfix operator ^:

let y = doSomething(x^)

The main reason for it to be postfix is to allow easy chaining with similar syntax to optional chaining:

// .value is just too long in some cases
let y1 = obj.property.value.whatever.value.sthElse.value
// prefix requires parentheses
let y2 = ^(^(^obj.property).whatever).sthElse
// postfix allows nice chaining
let y3 = obj.property^.whatever^.sthElse^

However, for ^ to really be useful there is probably also need for ^! and ^?, because with optionals you now have to use parentheses, which kind of defeats the whole purpose:

let z = (me.friend^)!.lastName^
@slazyk slazyk changed the title Observable value syntax when using Optionals New Observable value syntax (especially with Optionals) Aug 19, 2014
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