- Fix for
onChildAttachedTo
firing for current children even whenfireForCurrentChildren
was set to false.
- Fixed some types so they are compatible with TypeScript 5.6.
- Fixed some types so set transformations are compatible with TypeScript 5.5 once more.
- Some more minor optimizations, for example creating models should be around 10% faster now.
- Some optimizations, for example reading values should be around 2x faster now.
- Adds support for
YjsTextModel
frommobx-keystone-yjs
.
- Data model classes can now be passed as types directly, like model classes can.
- New! Y.js bindings for
mobx-keystone
are now available in themobx-keystone-yjs
package as well as a working example in the examples section of the online docs. - Added missing
nanoid
dependency to the list of dependencies.
- Fix so
onGlobalPatches
only generates the patches for new models when they are generated viafromSnapshot
. - Fix so new
onGlobalPatches
paths won't include '$' in their paths.
onGlobalPatches
will now get called for new models whenever the initial snapshot values where overridden by defaults or missing IDs.
- Performance improvements when using the "new" non-experimental standard decorators: do not use class proxies.
- Added support for "new" non-experimental standard decorators. The old ones are still supported.
- Some small optimizations.
- Fixed an error about finding types when using TS in bundler mode.
- Fixed a bug where an object was sometimes being detached and then again retached when using applySnapshot.
- Fixed a bug where the
onAttachedToRootStore
disposer was not being called for models inside arrays.
- Fixed a bug where extra
attachToRootStore
calls and patches were being made when usingapplySnapshot
to reconcile models with the same ID. - Speed up a bit Typescript types.
- It is now possible to override default values when extending a model, but it is now on the user side to ensure that the base and extended types are compatible.
- Added
maxUndoLevels
andmaxRedoLevels
toundoMiddleware
options to limit the number of undo/redo levels.
- Optimizations yielding around 10-15% less CPU time for some operations.
- Use a proxy to decorate model classes to reduce the inheritance level of models by one.
- Create object children cache only when there are actually children to save some memory in objects/arrays that don't have children of type object.
- Cache props/tProps to save some memory in model definitions.
- Big memory optimizations for model definitions with many properties (very little changes for model instances though). This change now makes Proxy support a requirement.
- Minor speed optimizations.
- TypeCheckError now includes a new
message
field, a newtypeCheckedValue
field and no longer requires a parameter for thethrow()
method. - Type checking error messages will now include the actual value that failed validation in the error message.
- Fixed an issue related to computed trees.
- Added
idProp.typedAs<T>()
to be able to type an ID prop with a string template.
- Since the API has been quite stable for a while I think it is time for a v1.0.0 release. :) No other changes.
- Fix for
applySnapshot
throwing an exception when removing a property which was not declared in the model.
- Fix for
standaloneFlow
typing.
- Attempt to fix react native bundling issues.
- Fix for a possible infinite recursive call when using
types.tag
.
- Fix
applySnapshot
so it respects default initializers. - Setting a prop that has a default value to
undefined
ornull
will set it to its default value (same as if it was done innew
orfromSnapshot
).
- Fixed an issue that prevent model actions/flows from being used when destructured.
ModelData
andModelCreationData
now take into account any possible transformations. If you want to use the old ones (without transformations) then useModelUntransformedData
andModelUntransformedCreationData
.
- Fixed an issue related to modelActions and modelFlows in derived classes giving an error on instantiation.
- Fixed an issue where value-types would always generate patches when
applySnapshot
was being used (even if the contents of the value-type did not really change).
- Added
types.tag
to be able to annotate types.
- Fixed
applySnapshot
generating no-op patches sometimes.
- Fixed
fromSnapshotProcessor
not accepting null or undefined when atProp
with a default value was used.
- Fixed react-native not picking up the right bundle.
- Fixed a bug related to sorting arrays producing patches that end up in a same node being temporarily twice in the tree.
- Reverted ESM splitting.
- Split the ESM version in several files to improve the tree-shakeability of the library.
- Removed side effects to improve the tree-shakeability of the library.
- Fixed a bug so
$modelType
should no longer be needed when it is defined withtProp
.
- Fixed an issue introduced in 0.67.0 related to the use of tProp and getting stale snapshots.
- Fixed an issue related wrong validation of tProps of nullable/undefinable arrays.
- Small optimization to some of the walk tree methods.
- Fixed a typing issue where statics would not be picked up by ExtendedModel.
- Improved model creation time by around 25% when using mobx 6 for models without mobx decorators.
- Big speedup in certain cases (when many mutations are done between
getSnapshot
calls) by delaying the immutable object creation to the point whengetSnapshot
is called. - Fixed typing issue related to generics with optional props.
- Fixed typing issue related to generics.
- Restored compatibility with mobx 4/5 and added CI tests to ensure it never gets broken again.
- Added
@computedTree
decorator for reactively deriving an alternative view of an original tree that is attached as a property to the original tree to support tree traversal functions, contexts, references, etc. (see "Computed Trees" section in the docs).
- Fixed a
Maximum call stack size exceeded
getting triggered whenonAttachedToRootStore
was defined and many nodes were added at once. - Added property transform
stringToBigIntTransform
. - Added action serialization for non-JSON primitive values
undefined
,bigint
and specialnumber
valuesNaN
/+Infinity
/-Infinity
.
- Fixed a typing issue related to models that use generics at multiple levels.
- [BREAKING CHANGE]
types.ref
now takes as an argument the reference constructor it needs to check for. - When
tProp
is used instead ofprop
then$modelType
won't be needed in input model snapshot for that particular property. As a side effect,$modelType
is now marked as optional in types. Note that for this to work for a root model instead of a sub-property you will need to use the newfromSnapshot
overload that takes a type as first argument. For untyped compatibility reasons,getSnapshot
will still return$modelType
even for typed models. - Added
withSnapshotProcessor
to class model properties. - Model classes can now be directly used as types instead of having to wrap them inside
types.model(...)
(except in recursive / self-recursive cases). - Simplified some typings to make them faster.
- Fixed a typing issue that would type
$modelId
asstring | undefined
. Now it will be typed asstring
when there is anidProp
andnever
when there is not.
- Added
FromSnapshotDefaultType<typeof props>
andToSnapshotDefaultType<typeof props>
so the default type does not need to be repeated when usingfromSnapshotProcessor
/toSnapshotProcessor
.
- [BREAKING CHANGE] The model override
fromSnapshot
has been removed in favor offromSnapshotProcessor
/toSnapshotProcessor
options ofModel
/ExtendedModel
. These allow you to set up pre/post snapshot processors for models.
- [BREAKING CHANGE]
$modelId
is no longer a requirement and will be no longer automatically added to models. If you want your models to keep using the old behavior (having a$modelId
property) then add a[modelIdKey]: idProp
or a$modelId: idProp
property to them. Note that$modelId
can still be used in instances to get/set the current ID property, just that it might be undefined (get) / throw (set) when there is none.
- Fix to avoid calling
onAttachedToRootStore
more more often than it should.
- Fixed a typing issue related to extending a class model with an
idProp
.
- Fixed
types.model
sometimes picking any as the model type. - Fixed type checking sometimes giving false errors upon reconciliation.
- Added
withTransform()
, a new way to do property transforms, as well as the pre-made transformstimestampToDateTransform
,isoStringToDateTransform
,objectToMapTransform
,arrayToMapTransform
andarrayToSetTransform
. See the docsMaps, Sets, Dates
section for more info. - Data models can now use default property initializers.
- Added
apply
andapplyComputed
to contexts so that they can be used to share information with models on creation time (kind of likeenvs
in Mobx-state-tree). See the context docs for more details. - Fixed an issue with
asMap
where the map would not get updated when the backing array/object changed. - Fixed an issue with
asSet
where the set would not get updated when the backing array changed.
idProp
now correctly handleswithSetter
.
- Switched bundler from microbundle to vite.
- Deprecated prop modifier variant
withSetter("assign")
, usewithSetter()
instead. - Changed to nanoid from uuid for model id generation.
- Added
swap
to array actions.
- Added
package.json
to the exports list to avoid issues with metro bundler from react native.
- Added
createGroup
toundoMiddleware
, which allows to group several actions perform in separate code blocks. - Added an overload to
toTreeNode
that accepts a type checker as first argument. - Added standalone actions. See the relevant section of the docs for more info.
- Added
attachedState
to theundoMiddleware
. Useful to save/restore state related to actions but that shouldn't be part of the undo/redo event queue (e.g. selection, text editor cursor position, etc.). - Added
findChildren
to be able to find all children of a subtree root node for which a predicate matches. - Improved support for generics when using references.
- Generic types are now inferable from the constructor parameters
- Fixed an issue where
idProp
on the base was not being picked up byExtendedModel
.
- Added a simpler pattern for generic models when using
prop
. - Added
resolveId
to be able to resolve a model given its ID.
- Fixed an issue when importing the package with expo.
- Made
getRefsResolvingTo
able to get updated results when called inside an action (as long as the reference being back-traced and the target are children of the same root).
- Fixed an issue with typings not working properly for model properties (probably introduced in v0.55.0).
- Fixed webpack import section in
package.json
. - Made
onInit
,onAttachedToRootStore
andonLazyInit
protected.
types.model
andtypes.dataModelData
no longer require the type as a generic argument in TypeScript for non-recursive cases.
- Changed build tooling.
- [BREAKING CHANGE]
setterAction: true
prop option is nowprop().withSetter()
- [BREAKING CHANGE]
setterAction: "assign"
prop option is nowprop().withSetter("assign")
- [BREAKING CHANGE] Functional models have now been removed in favor of Data models, which serve a similar function while having a syntax closer to standard class models. See the relevant new section in the docs for more info.
- [BREAKING CHANGE] Property transforms have been removed (including 'prop_mapArray', 'prop_setArray', ...). Consider switching to 'objectMap', 'asMap', etc. or a getter/setter with a transform inside pattern.
- [BREAKING CHANGE] Property transform decorators have been removed.
- [BREAKING CHANGE - types] Some type helpers have been renamed:
ModelPropsData
/ModelInstanceData
->ModelData
,ModelPropsCreationData
/ModelInstanceCreationData
->ModelCreationData
. onSnapshot
now also takes a function that returns a node.- Added
valueType
option toModel
/ExtendedModel
so that class models of that kind automatically get auto-cloned when assigned to a property/array/etc., useful for example for primitive data structures such as points, colors, etc. Check the relevant section of the docs for more info
- Added
withGroupFlow
toUndoManager
so that several async actions can be undone/redone as a single step.
- [BREAKING CHANGE] Now requires TypeScript 4.2.0.
- [BREAKING CHANGE] Class model
setterAction: true
prop option will now generate a setter likesetX
automatically instead of making the property assignable. To get the old behaviour usesetterAction: "assign"
instead. - [BREAKING CHANGE] Functional model
setterActions
now just take the field names rather than an object with the setter mapping. - Fixed an issue when using
ExtendedModel
with abstract classes in TypeScript 4.2.0. - Fixed committing non-idempotent sandbox changes to the original subtree.
- Added
withGroup
toUndoManager
so that several sync actions can be undone/redone as a single step.
- Fix for broken library build.
- Added
withoutUndo
andisUndoRecordingDisabled
toUndoManager
. Consider using those instead of the globalwithoutUndo
if more precision over whichUndoManager
to skip recording to is needed.
- It is now possible to use a custom property as model id instead of
$modelId
by assigning to a property the newidProp
value. In any case, model instances can still usemodel.$modelId
to read/write this custom property if desired.
- [BREAKING CHANGE] The sandbox manager's
withSandbox
method now requires an array of nodes from the original tree and the corresponding sandbox nodes are now positional arguments of the callback function. - Fix for a possible issue when using
applySnapshot
with hot reloading.
- Fixed incompatibility with MobX >= 6.1 (in order to fix it
$modelId
is now an enumerable property though). - Fixed the sandbox to group commit patches so that the undo manager will undo the commit in a single step.
- Added
assign
tofnObject
.
- Fixed TypeError path for refinement types.
- Fix for the undo manager so it will correctly group reference invalidations inside the action that caused it.
ExtendedModel
will now throw when thebaseModel
argument is not a model class.
- Remove
require
usage from esm modules to fix snowpack compatibility.
- Added
showDuplicateModelNameWarnings
to the global config.
- Fixed compatibility with MobX v5 and v4 when using ESM build.
- Made it compatible with MobX v6 while keeping it compatible with v5 and v4 still.
- Make the typing of some functions not rely on mobx internal typings.
- Added
onPatches
callback option to thepatchRecorder
. - The
events
list in thepatchRecorder
is now an observable array. types.enum
no longer requires the generic type in typescript, the enum object as parameter is enough.
- [BREAKING CHANGE] Runtime type-checking of objects will no longer complain about excess properties, they will just be ignored.
- Fixed an issue related to typing changes of the generated types optimization for extended models.
- Fix: The type of data inside frozen is no longer forced to be
DeepReadonly
. This fixes a possible issue where the type might no longer be assignable with itself.
- Fix:
onAttachedToRootStore
will still be invoked after all model actions are finished (as it was before), but now before other user reactions are triggered.
- Fix:
allowUndefinedArrayElements
now also applies to frozen data. - Optimized a bit the generated typings for extended models.
- Fixed a bug when calling an undo-able model action from a non undo-able parent model.
- Added
allowUndefinedArrayElements
global config option to allow arrays to takeundefined
elements.
- Added
assertIsTreeNode
, which asserts if an object is a tree node or throws otherwise.
- 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.