An experimental and WIP approach to a type safe and self traversing REST client.
Usage
;;; /div; ; renderConnectedView /;
Assumptions
As mentioned, this lib has opinions about how a REST endpoint and how the data it returns looks:
- All entities can be uniquely identifiable by an
id
key. - The API is self describing via HATEOAS metadata stored under a
__links
key.
Resolving relations via HATEOAS
; ; ; console.logfirstBooksAuthors.state.response.name;
Connecting multiple views to the same API
;;; ; ;; // We'll have a single container querying the API and multiple// views listening to it.;; renderdiv ConnectedView1 / ConnectedView2 //div;
Testing
You can create stores with mocked data for use in tests:
; ; console.logmock.state.loading; // falseconsole.logmock.state.response; // { id: 1, foo: 'bar' }