-
Notifications
You must be signed in to change notification settings - Fork 75
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
ability to specify a type for derived properties #116
base: master
Are you sure you want to change the base?
Conversation
Hey @flipside, thanks for submitting this! I think I'm heading towards +1 on this idea. I've a couple of thoughts though - forgive me if I'm being slow. First up: what does |
@latentflip, by my read it looks like |
@aaronmccall @latentflip i wasn't sure if it should always automatically set a derived property on load if a type is set so I made them separate params. i'm open for init to default to true when a type is specified but i can imagine situations where it would be important to override. |
the other thing worth discussing is that since this approaches uses dataType, should it go all the way with using get/set/default and not just compare? |
adding support for default and the rest of the dataType functions turned out to be easy and didn't break tests so i added them. |
@@ -437,16 +454,17 @@ assign(Base.prototype, Events, { | |||
}, this); | |||
}, | |||
|
|||
_getDerivedProperty: function (name, flushCache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we're getting rid of flushCache?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing cos it's not used. Doesn't appear to be being used by any other modules as per a github search. What do you think about removing it @HenrikJoreteg? Can you remember if it's useful/needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know at one point or another i wanted to be able to do this forcibly. But can't remember why. If it's not being used and everything passes, then we're probably good.
one debatable part is supporting |
By specifying a dataType for derived properties, a derived property with
type:"state"
can dynamically have listeners updated when it returns a different state.Derived types also allow for custom behavior by adding new dataTypes.