-
Notifications
You must be signed in to change notification settings - Fork 40
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
Have scheme work for collections of items #75
Comments
agreed. This bugs me as well. I find myself operating directly on Not sure I follow exactly what you are proposing. Other frameworks, such as Backbone, have solved this by mixing in a library like underscore, and I'm not sure I want to introduce a dep like that. Can you be more specific about how you envision this working? |
From an API point of view, i might suggest something like this: Store is a single 'model' (same as now): var Artist = Flux.createStore({
scheme: {
firstName: {
default: 'Unknown'
},
lastName: {
default: 'Artist'
}
}
}); Store is a collection of 'models': var Artists = Flux.createStore({
collection: true,
scheme: {
firstName: {
default: 'Unknown'
},
lastName: {
default: 'Artist'
}
}
}); In my own stores of this nature I also have the methods add, remove and update that could work something like: Artists.add({
id: 1,
firstName: 'Elvis',
lastName: 'Presley'
});
Artists.update({id: 1}, {
firstName: 'Lisa'
});
Artists.remove({id: 1}); Calling set on this store would throw an error. Maybe this is overkill? Honestly I'm not sure if this is the direction that you want to take delorean or not, it's definitely moving into the backboney arena but that might be a good a thing as I think there will be a lot of folks moving over and hoping for a little more sugar. |
It would be nice if the scheme validation and calculation methods also worked for a collection of items as this is typically how Flux stores are arranged. If we discuss some syntax I can probably take this on... my thinking is another attribute on the stores isCollection: true for example.
The text was updated successfully, but these errors were encountered: