-
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
Allow for nested props #148
Comments
Just use: var Graph = require('./models/graph');
//...
children: {
graph: Graph
} and it will be automatically accessible and will bubble events and all ;-) |
Thanks @pgilad. While I understand that's a way to do that, it's not effecient. If I have a JSON response three levels deep, I've created three files, two of them unnecessary if there was a way to nest props. |
Hey @mike-engel, while I agree that there could be an easier way, I'm not sure what or how that would look internally (or how feasible it would be to implement). I've run into this problem in the past, and my solution was to not break up the nested child models into separate files, and instead create the model definitions as local variables. I know this isn't a solution, but it at least helped me not create too many extra files. |
@lukekarrys I think a possible solution would be to dynamically create the children & collections in order to support nested properties. I would create them all with default values (allowing any sub-property type). and thus user will have access to the nested properties (including events). If a user wants to customize and/or add more logic to the nested props, he should create a child model or collection by himself |
I think it would be a good idea to allow for nested props when extending ampersand-state or ampersand-model. I'm not quite sure what the best way would be to do this, but right now to nest props in a model it's a pain. I don't expect this scenario to be all that uncommon. If there's interest, there'd need to be a discussion about the best syntax, etc.
Here's an example response from our server:
Right now, I have to do something like this for nested props:
It would be super nice to have the entire definition in one file. Something like:
or
Maybe I just haven't experimented enough with this where the first one would work. Thoughts?
The text was updated successfully, but these errors were encountered: