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!
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 theModel.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
andremoveAll
(instead ofread
anddestroy
), maybereadAll
,destroyAll
. This give more flexibility when you want to pass options throughall
, 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!