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 theskipCachepropertyfetchAll- Second argument (force) moved to the options object as theskipCachepropertyrequest- Stays the same, but will be cached if it's a 'GET' method, unlessskipCacheis set totrue
Record changes
Same:
save- Stays the same
Changed:
getMeta- UsegetModelMetagetLinks- UsegetModelLinksfetchLink- UsefetchModelLinkgetRelationshipLinks- UsegetModelRefLinksfetchRelationshipLink- UsefetchModelRefLinktoJsonApi- UsemodelToJsonApisaveRelationship- UsesaveRelationshipremove- Renamed todestroysetPersisted- 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 ofdefaultFetchOptionsstoreFetch- Removed in favour oftransformRequestandtransformResponse