Open NullVoxPopuli opened 8 years ago
I've learned that js-data uses Promises, and for Angular2, apparently it's recommended to use Observables, due to lazy loading, cancel-ability, and re-run-ability (Promises are eager, can't be cancelled, and only resolve once).
So there are probably different scenarios in which we'd want to use both? idk. I think it depends on what the data store is trying to do.
it may be worth just starting with vanilla js-data: http://www.js-data.io/docs/home
api looks similar to what we want: http://www.js-data.io/docs/working-with-the-data-store
life cycles are already implemented: http://www.js-data.io/docs/model-lifecycle
I read through the docs and although the syntax is nice, I don't think it plays well with angular's way of separating models from model services. We can definitely use some of their ideas though.
class User extends JsonApiModel {
name: string
posts: Array<Post>
}
@JsonApiModelConfig({
endpoint: '/users',
// ...
})
class UsersService extends JsonApiModelService<User> { }
Well, do you think it would be worth trying it out, so we don't have to do a bunch of re-inventing?
they have an angular2 example here: https://github.com/js-data/js-data-examples/blob/v2/client/angular2
so, at this point, I think I'd be better to write a jsonapi adapter for js-data
https://github.com/js-data/js-data-angular
might neat to utilize that, haven't found anything saying it supports angular 2, though. :-(