-
Notifications
You must be signed in to change notification settings - Fork 41
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
maxProperty doesn't have a good way to use "default" #77
Comments
This is tricky. It seems like a few cases are not covered:
I think the behavior you're suggesting is perfect for Thoughts, @jayphelps? |
.. and on the |
@jamesarosen so I have a good understanding, what's a use case for binding the property, but the value is undefined/null but it is not a bug? I've found myself more and more not doing these sort of "I can't use the value, fall back to default" because they tend to mask bugs in apps that later are hard to track down. Instead, I usually prefer to either throw an actual error or fallback with a |
My use-case: I'm building a component that wraps nf-graph. It has a My implementation is // my-graph.js
yMax: computed("unit", function() {
return this.get("unit") === "percent" ? 100 : undefined;
}) Alternatively, I could pass in something like "auto" to indicate I want the default behavior. |
@jamesarosen that seems like a very valid case. I dig your suggestion for |
In that case, the docs might read something like
And my example might look something like {{nf-graph yMax=(if isPercent 100 "auto")}} |
It's tricky. I sort of view the value the graph was initially set with to be the "default", not necessarily the coded default. It seems like we could memoize that when it's initialized, somehow. I think passing Perhaps it should be like this: {{#nf-graph xMax=someValue xMaxDefault=100}} Where if However, in the event that Thoughts? |
What's the current behavior if I set |
It should behave the same as a 0, I think. |
So you want
|
I really depends on the |
@Blesh can you give me very specific requirements? I need to work on this this week to ship a feature. I can make up an implementation that works for me, but I'd rather do something that will get merged here (eventually). |
different
When in doubt, use Does that help? |
These
Given that, I would guess something like {{nf-graph yMax=100
yMin=0
yMaxMode=(if isZoomed "push" "fixed")
yMinMode=(if isZoomed "auto" "fixed")}} |
I'm totally cool with setting {{nf-graph yMax=(if isZoomed "auto" 100)}} |
The method that is going to give you the most control will be using |
For example, maybe your array is already sorted, or maybe your service already gave you the min and max values, and you can just pick them out of an object or an array without having to iterate over that array. |
😄 If I don't pass a
yMax
, I get a nice default behavior:😄 If I do pass a
yMax
, I can get a nice override:😢 But there's no way for me to use
yMax=someBoundProperty
that might beundefined
or might be an integer. If it's undefined, thenyMax
gets set toundefined
, not to the default behavior.I think an easy solution would be to change the logic in the
maxProperty
to use the override only if it's notnull
:The text was updated successfully, but these errors were encountered: