Skip to content

Commit 066e5e9

Browse files
committed
Add model getter documentation to Rest API example
1 parent 24acf89 commit 066e5e9

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

examples/rest-api-example/README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,45 @@ The following interface is required for a model to properly work with `createApi
183183

184184
**`Model.entity : String`**
185185

186-
**`Model.fetch(params : any) : Promise`**
186+
**`Model.fetch( params : any ) : Promise`**
187187

188-
**`Model.fetchAll(params : any) : Promise`**
188+
**`Model.fetchAll( params : any ) : Promise`**
189189

190-
**`Model.save(instance : Object) : Promise`**
190+
**`Model.save( instance : Object ) : Promise`**
191+
192+
**`Model.delete( instance : Object ) : Promise`**
193+
194+
195+
## Entity Getters
196+
197+
**`RestApi.createEntityMapGetter( model ) : Getter`**
198+
199+
Creates a getter for a specific model that references the `restApiCache` map of entity id => entity.
200+
201+
**`RestApi.createByIdGetter( model ) : function`**
202+
203+
Creates a function that returns a getter that references a specific entity by id in the `restApiCache` map.
204+
205+
**Usage**
206+
207+
```js
208+
Project.actions.fetchAll()
209+
210+
flux.observe(Project.getters.entityMap, projectMap => {
211+
console.log('project rest api cache changed', projectMap.toJS())
212+
})
213+
```
191214

192-
**`Model.delete(instance : Object) : Promise`**
193215

194216
## TODO
195217

196218
### v1
197219

198220
- [x] Complete testing the `createApiActions` method 100%
199-
- [ ] Implement travis.ci badge for coverage
200221
- [x] add example entity module
201222
- [x] Update rest-api-example README with architecture overview
202223
- [x] Update rest-api-example README example model
203-
- [ ] Update rest-api-example README with getter pattern for rest api modules
224+
- [x] Update rest-api-example README with getter pattern for rest api modules
204225
- [ ] Link to README / example in main NuclearJS README
205226
- [x] Cleanup components / gulp / webpack configs
206227

0 commit comments

Comments
 (0)