beauby / angular2-jsonapi

Full-fledged JSON API client for angular2.
MIT License
2 stars 1 forks source link

Possibly hook up with js-data-angular? #1

Open NullVoxPopuli opened 8 years ago

NullVoxPopuli commented 8 years ago

https://github.com/js-data/js-data-angular

might neat to utilize that, haven't found anything saying it supports angular 2, though. :-(

NullVoxPopuli commented 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.

NullVoxPopuli commented 8 years ago

it may be worth just starting with vanilla js-data: http://www.js-data.io/docs/home

NullVoxPopuli commented 8 years ago

api looks similar to what we want: http://www.js-data.io/docs/working-with-the-data-store

NullVoxPopuli commented 8 years ago

life cycles are already implemented: http://www.js-data.io/docs/model-lifecycle

beauby commented 8 years ago

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.

beauby commented 8 years ago
class User extends JsonApiModel {
  name: string
  posts: Array<Post>
}

@JsonApiModelConfig({
  endpoint: '/users',
  // ...
})
class UsersService extends JsonApiModelService<User> { }
NullVoxPopuli commented 8 years ago

Well, do you think it would be worth trying it out, so we don't have to do a bunch of re-inventing?

NullVoxPopuli commented 8 years ago

they have an angular2 example here: https://github.com/js-data/js-data-examples/blob/v2/client/angular2

NullVoxPopuli commented 8 years ago

so, at this point, I think I'd be better to write a jsonapi adapter for js-data