component / model

Minimalistic extensible data models
122 stars 40 forks source link

Pulling the AJAX sync transport out of model #29

Closed matthewmueller closed 11 years ago

matthewmueller commented 11 years ago

This is a first pass at pulling out the sync transport from this component. The model component could probably use a Model.sync(obj) or something.

I went with the CRUD approach inspired by backbone's sync, but I wanted more flexibility in what gets passed through (no big options object). This allows the Model.all, Model.get, obj.save, etc. to basically act as shells to the transports, allowing any number of arguments, with the last being the callback.

One thing I'm trying to work out is whether or not to just add additional methods for all and removeAll (instead of read and destroy), maybe readAll, destroyAll. This give more flexibility when you want to pass options through all, like limits and filtering, but is more work for those implementing the transports.

All the tests pass with these changes. And as always, open to suggestions, modifications, etc!

matthewmueller commented 11 years ago

Much better to extend all, removeAll, get, save, update & remove. Mapping to CRUD adds needless complexity. Will open another PR later.