- Fixed an issue with automatic setter actions not working when the model included computed properties.
- [BREAKING CHANGES]
applyCall
has been renamed toapplyMethodCall
- consider usingfnObject.call
though.arrayAsMap
,ArrayAsMap
were removed (seeasMap
for a replacement).arrayAsSet
,ArrayAsSet
were removed (seeasSet
for a replacement).objectAsMap
,ObjectAsMap
were removed (seeasMap
for a replacement).
- Added
asMap
andasSet
, which are similar to the oldarrayAsMap
, etc. except that they take the data object directly. - Added
fnModel
as a functional alternative to models that do not require$modelId
or$modelType
(see the relevant section on the docs for more info). - Added
tag
to be able to tag objects with extra data (useful for functional models for example). - Added
fnObject
andfnArray
to be able to directly manipulate objects/arrays without the need of predefined model actions.
- Fixed issue with updated uuid dependency.
- Added the model property option
setterAction
so that it automatically implenents model prop setters wrapped in actions. - Added
applySet
,applyDelete
,applyCall
to be able manipulate data without the need to usemodelAction
.
- When using date transforms, mutation made by methods (
setTime
, etc.) are reflected in the backed property (string / timestamp), so it is no longer required to treat dates as immutable objects. - Performance improvements for implicit property transform collections.
- [BREAKING CHANGE - types] Some type helpers have been renamed:
ModelData
->ModelPropsData
/ModelInstanceData
,ModelCreationData
->ModelPropsCreationData
/ModelInstanceCreationData
. - New feature: "Implicit property transforms", which are sometimes preferred over the old decorator based property transforms, collection wrappers (
arrayAsSet
,arrayAsMap
,objectAsMap
) and collection models (ArraySet
,ObjectMap
). Check the "Maps, Sets, Dates" section in the docs for more info. - Added
types.tuple
. - Property transforms decorators can now also be used standalone.
- Added
decoratedModel
so the library can be used without decorators.
- Fixes for
undoMiddleware
, where it wouldn't properly record changes outside a subaction after a subaction is performed. applyPatches
now supports arrays of arrays of patches.- Improved reconciliation - now
applyPatches
andapplySnapshot
are more likely to reuse instantiated model objects whenever possible rather than recreating them anew (as long as their model types and ids match). - Added
isSandboxedNode
andgetNodeSandboxManager
to be able to tell when a node is sandboxed / which is its sandbox manager (if any).
- Deprecated
abstractModelClass
, which should not be needed anymore. - Added
modelClass
to better support base models with generics. - A few type optimizations.
- Fixed undo middleware regression (not properly undoing) that happened in v0.33.0.
- Made
applySnapshot
not check by model instance in reconciliation for better compatibility with hot-reloading. - Fixed
ObjectMap.forEach
andArraySet.forEach
typings.
- Added new way / guide to use the factory pattern when
declaration
option is set totrue
intsconfig.json
.
- [BREAKING CHANGE]
onAttachedToRootStore
and its disposer will be called after all actions are finished. - Improvements to ensure
onAttachedToRootStore
and its disposers are called in a more reliable manner. getRootPath
,getRoot
,getRootStore
are now internally computed, so they should be faster when being observed.- Warnings about duplicate model names will now only show once per model.
- Optimized the patches generated for array operations.
- Added support for obtaining multiple sandbox nodes at the same time.
- Added
$modelType
as static property to model classes, as well as a bettertoString()
to model classes and instances for logging purposes. - Static properties now will be preserved in classes that use the model decorator.
- Fixed an issue with wrong patch order being generated for actions triggered inside
onAttachedToRootStore
. - Added support to
applyPatches
for applying patches in reverse order. - Fixed applying inverse patches in reverse order.
- Added
sandbox
to create a sandbox copy of the state for testing "what-if" scenarios; changes can be either committed to the original state or rejected (see Sandboxes section in the docs).
- Added
deepEquals
to deeply check for equality standard values, observable values, and tree nodes. - Added
draft
to create drafts of parts of the state that can be later committed to it (see Drafts section on the docs).
- Fixed an issue with the readonly middleware where sometimes it was possible to write to a protected node when the write was being done from an unprotected parent node action.
- It is now possible to use
ExtendedModel
over classes that use the@model
decorator.
- Made
isRootStore
reactive.
onAttachedToRootStore
and its disposer will be called right after a change is made rather than after a whole action is finished (restores behaviour of version <= 0.28.1).
- Improve a bit the atomicity of
modelAction
/runUnprotected
.
- Fix: modifying a node inside
onAttachedToRootStore
or its returned disposer no longer results in broken snapshots.
- Updated min Typescript version to 3.7.
- [BREAKING CHANGE] If you want to use
ExtendedModel
over an abstract class now it must be done likeExtendedModel(abstractModelClass(SomeAbstractClass), { ... })
.
- Added
getTypeInfo(type: AnyType): TypeInfo
to get runtime reflection info about types.
- Simplified types.or typing.
- Switched an error to be a warning instead when using hot reloading.
- Added a ponyfill fallback for btoa for React Native.
- Fix compatibility with babel decorators.
- Fixed type generation.
- Optimized types a bit.
- Made it impossible in Typescript to give a default value for an object type without using a default value generator function to avoid possible mistakes.
- Fixed
applySerializedActionAndTrackNewModelIds
so it won't track$modelId
changes for plain objects. - Added
Path
andPathElement
types.
- Fixed an issue with back-references and
onResolvedValueChange
not working when references were being restored from a snapshot.
- Small optimization for
applySerializedActionAndTrackNewModelIds
so it doesn't traverse frozen values.
- Added
applySerializedActionAndTrackNewModelIds
andapplySerializedActionAndSyncNewModelIds
. Prefer those overdeserializeActionCall
plusapplyAction
when applying serialized (over the wire) actions in order to avoid$modelId
desynchronization. - Added a default implementation of
getRefId()
which returns$modelId
.
- Fixed wrong patches being generated for array splices sometimes.
- [BREAKING CHANGE] Allow to pass
$modelId
to model creation data to override it rather than using a special symbol. - [BREAKING CHANGE] Removed
overrideRootModelId
tofromSnapshot
andclone
, but made$modelId
in models editable instead.
- Added
overrideRootModelId
tofromSnapshot
andclone
.
- Added options parameter to
clone
.
- [BREAKING CHANGE] Added a
$modelId
extra property to models and their snapshots in order to be able to properly validate targets of serialized actions in scenarions with concurrent clients. Also allows the automatic optimization of the serialized version of models in action parameters by substituting them to just their paths + path of ids whenever possible. - [BREAKING CHANGE] Default values for properties will now also apply when the initial data is
null
. serializeActionCall
,serializeActionCallArgument
,deserializeActionCall
anddeserializeActionCallArgument
now can take a second parameter with the root node of the model where actions are going to be performed to optimize the serialization of arguments that are already in the store.- Added
registerActionCallArgumentSerializer
for serialization of custom action argument types. ActionContext
now includestargetPathIds
.- Added
pathObjects
togetRootPath
. - Improved a bit the typing for
fromSnapshot
model methods. - Added property transforms via
propTransform
. - Improved action argument serialization so it supports dates, maps, sets, arrays of models, etc.
arrayAsMap
now supports arbitrary key types.
- Added
tProp
syntactic sugar for optional primitives with a default value. - Added
String
,Number
,Boolean
,null
,undefined
as aliases for primitive types. - Added
findParentPath
.
- [BREAKING CHANGE] Paths to model properties will no longer report interim data objects (
$
). This means that properties are now direct children of model objects, which should be cleaner and more understandable.
- Fixed a possible memory leak with refs.
- Optimizations for
rootRef
resolution when the node cannot be resolved.
- Added
isRefOfType(ref, refType)
to check if a ref is of a given ref type. - Added
getRefsResolvingTo(node, refType?)
to be able to get back references that are currently pointing to a node.
- Added
setDefaultComputed
andgetProviderNode
to contexts. - [BREAKING CHANGE]
getChildrenObjects
will now never report interim data objects ($
). - Optimizations to
getChildrenObjects
andonChildAttachedTo
. - Added
rootRef
s.
- Added contexts to share information between parents and children and to make isolated unit testing easier.
- Models can now optionally offer a
getRefId()
method that can be automatically used by custom references to get their ids, thus makinggetId
for custom references optional now.
- Fix path for ESM module.
- Added UMD modules and specify proper module for react-native, add tslib to dependencies.
- Fix issue with babel transpilation that would end up in some runtime errors.
- Fixed
onChildAttachedTo
disposer typing.
- Better support for array / object spreading, reassign to filter/map, etc. Objects and arrays will be automatically unconverted from tree nodes when detached.
- [BREAKING CHANGE] Again changes to flows so typings are better. Check the updated flow section of the documentation to see how to work with them now (should be much easier).
- [BREAKING CHANGE] Using flows in TypeScript should result in improved typings, but it requires TypeScript >= 3.6.2. Check the updated flow section of the documentation to see how to work with them now.
- Fixed
getChildrenObjects
andonChildAttachedTo
so they don't report the model data objects ($
). Set the optionincludeModelDataObjects
to true to get the old behaviour back ingetChildrenObjects
.
- Fixed an issue with a workaround for abstract classes setting values on the constructor when using babel.
- Added
getParentToChildPath
,getChildrenObjects
andonChildAttachedTo
, and some performance improvements.
- Fixed an issue with ExtendedModel when user library was compiled using ES6 classes.
- Improved support for abstract base models.
- Renamed error class to MobxKeystoneError from MobxDataModelError.
- Updated dep with proper fixed version.
- Revert dep update that broke some types.
- Slight performance improvements. Basic benchmarks.
- Added
ExtendedModel
and a doc section about subclassing.
- Slight performance bump by moving decorators to the prototype.
- Fixed compatibility with mobx4.
- Added a second parameter to
getParent
to skip model interim data objects. - Added
isModelDataObject
function.
- First public release.