-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[RFC] Make computed.or return truthy object rather than true #10251
Comments
i would also love this 👍 we should see if this has backwards compatible issues. also, |
Would this be something that could get a PR quickly and move it forward? Extremely useful! |
likely yes |
I have no problem putting a PR up for this, expect one tonight if nobody else gets to it first. |
👍 |
How is this different from |
@ahacking it isn't, we should deprecate any, no reason to have both. |
@stefanpenner OK cool, I support deprecating When getting up to speed on Ember I first reached for +1 |
This week I came across this issue and even searched through API but couldn't find method that returns
or:
Btw. I still don't know how to reference I've noticed |
Implementation-wise |
Thinking about this a little more, the null return value probably is important in template rendering. The way javascript undefined || null // => null
null || undefined // => undefined
null || false // => false It makes sense to me to do that in |
The current behavior of
Ember.computed.or
will returntrue
I propose that it would be useful to instead return the truthy object, which more-closely matches the semantics of JavaScript
||
. This could makecomputed.or
more-useful for rendering templates (you seldom want to rendertrue
, but may want to render one of theor
ed objects).Example use case:
I can see this tripping people up who have written implementations depending on a
computed.or
property being=== true
. In other words it has potential to break apps depending on the existing behavior.The text was updated successfully, but these errors were encountered: