Skip to content

Releases: CodeYellowBV/mobx-spine

v0.13.0

22 May 13:44
Compare
Choose a tag to compare
  • Breaking change: throw error when an observable and a relation have the same name. This did work before, but could lead to very strange bugs.
  • Add models sorting with a comparator;
store.comparator = 'name'; // To sort on `name` attr on models
store.sort(); // To trigger a manual re-sort

store.comparator = (a, b) => (a.id - b.id); // Pass function for more complex sorting
  • Make it easy to disable/modify snake <-> camel case converting of attribute keys. If you have a backend that does use e.g. camelCasing, you can disable this conversion by adding this to your model:
toBackendAttrKey(attrKey) { return attrKey; }
fromBackendAttrKey(attrKey) { return attrKey; }

v0.12.0

11 May 13:45
Compare
Choose a tag to compare
  • Adds a new store.virtualStore() method, so you can filter on a store while keeping a store instance. All data from the new store will be kept in sync with the original store. It is inspired by backbone-virtual-collection.
const animals = AnimalStore();
const animalsWithOwners = animalStore.virtualStore({
  filter: model => !!model.owner,
});
  • Adds a new model.saveFromBackend() method, use it e.g. when the backend doesn't return the model after calling model.save(). Sometimes the model is created async in the backend so you can't parse the response (or you want to modify it).

  • Binder API only: when a relation is camelCased, the request to the backend was not parsed to snake_case (?with=pastOwners instead of ?with=past_owners).

  • Breaking change: model.saveAll() doesn't save all relations by default now, you need to specifically include the relations you want (model.saveAll({ relations: ['owner'] }).

v0.11.4

11 May 13:39
Compare
Choose a tag to compare

Allow url property on a store to be a method

v0.11.3

11 May 13:40
Compare
Choose a tag to compare

Fix for backend not returning full response in multi-PUT

v0.11.2

01 May 14:57
Compare
Choose a tag to compare

Fix issue with moment and timezones not being applied when using Casts.datetime.

v0.11.1

01 May 12:38
Compare
Choose a tag to compare

Fix model.clear() not correctly clearing observable arrays and objects when they were mutated.

v0.11.0

01 May 11:38
Compare
Choose a tag to compare
  • Add initialize() method to store and model (noop by default), which you can use to override and do something when class is initialized.
  • Add setFetchParams() method to model, so you can set default query parameters that are used when fetching.

v0.10.0

27 Apr 15:53
Compare
Choose a tag to compare
  • Add store.removeById() method, you can provide it an array of ids to remove.
  • Fix issue with backendResourceName and multiple relations of the same name.

v0.9.0

18 Apr 14:56
Compare
Choose a tag to compare

When using model.toBackendAll(), the name of the relation is sometimes
not the same as the name of the model or store. e.g.

relations() {
	return { activities: ActivityStore };
}

But the backend knows the activities relation by the name activity.
To fix this, you can now set backendResourceName on a model or store:

class ActivityStore extends Store {
	static backendResourceName = 'activity';
}

v0.8.0

14 Apr 12:02
Compare
Choose a tag to compare
  • A model now has a cid property, which is a globally unique value. You can use this e.g. in React in the key prop.
  • Allow newer versions of axios.
  • Use pkg.module instead of pkg.browser in package.json, since support for that is better apparently.
  • Allow custom versions of moment to be used as property (e.g. a version with custom locales).