Mobx jsonapi store
Since mobx-jsonapi-store is relying on mobx-collection-store, you also need to apply the mobx-collection-store migration.
Model and Collection definition
Model and Collection definition examples use Model
and Collection
, but it would work the same way for CompatModel
, PureModel
, or CompatCollection
.
Code diff
-- import { Store, Record } from 'mobx-jsonapi-store';
++ import { Collection, Model } from 'datx';
++ import { jsonapi } from 'datx-jsonapi';
// Collection definition
-- class AppStore extends Store { /* ... */ }
++ class AppStore extends jsonapi(Collection) { /* ... */ }
// Model definition
-- class Person extends Record { /* ... */ }
++ class Person extends jsonapi(Model) { /* ... */ }
Store changes
Same:
sync
- Stays the samedestroy
- Stays the same
Changes:
fetch
- Second argument (force
) moved to the options object as theskipCache
propertyfetchAll
- Second argument (force
) moved to the options object as theskipCache
propertyrequest
- Stays the same, but will be cached if it's a 'GET' method, unlessskipCache
is set totrue
Record changes
Same:
save
- Stays the same
Changed:
getMeta
- UsegetModelMeta
getLinks
- UsegetModelLinks
fetchLink
- UsefetchModelLink
getRelationshipLinks
- UsegetModelRefLinks
fetchRelationshipLink
- UsefetchModelRefLink
toJsonApi
- UsemodelToJsonApi
saveRelationship
- UsesaveRelationship
remove
- Renamed todestroy
setPersisted
- Removed
Config changes
Same:
baseUrl
- Stays the samefetchReference
- Stays the samedefaultFetchOptions
- Stays the sameparamArrayType
- Stays the samebaseFetch
- Stays the sametransformRequest
- Stays the sametransformResponse
- Stays the same
Changed:
defaultHeaders
- Removed in favour ofdefaultFetchOptions
storeFetch
- Removed in favour oftransformRequest
andtransformResponse