Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobx-state-tree

Package Overview
Dependencies
Maintainers
3
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree - npm Package Versions

1
13

3.1.1

Diff

Changelog

Source

3.1.1

  • Fixed typings of getParent and getRoot. Fixes #951 through #953 by @xaviergonz
mweststrate
published 3.1.0 •

Changelog

Source

3.1.0

  • Fixed issue where snapshot post-processors where not always applied. Fixes #926, #961, through #959 by @k-g-a
mweststrate
published 3.0.3 •

Changelog

Source

3.0.3

  • Fixed re-adding the same objects to an array. Fixes #928 through #949 by @Krivega
mweststrate
published 3.0.2 •

Changelog

Source

3.0.2

mweststrate
published 3.0.0 •

Changelog

Source

3.0.0

Welcome to MobX-state-tree! This version introduces some breaking changes, but nonetheless is an recommended upgrade as all changes should be pretty straight forward and there is no reason anymore to maintain the 2.x range (3.0 is still compatible with MobX 4)

Most important changes

MST 3 is twice as fast in initializing trees with half the memory consumption compared to version 2:

Running yarn speedtest on Node 9.3:

| | MST 2 | MST 3 | | --------------- | ------ | ------ | | Time | 24sec | 12 sec | | Mem | 315MB | 168MB | | Size (min+gzip) | 14.1KB | 15.0KB |

Beyond that, MST 3 uses TypeScript 2.8, which results in more accurate TypeScript support.

The type system has been simplified and improved in several areas. Several open issues around maps and (numeric) keys have been resolved. The frozen type can now be fully typed. See below for the full details.

Also, the 'object has died' exception can be suppressed now. One should still address it, but at least it won't be a show-stopper from now on.

Changes in the type system

  • [BREAKING] types.identifier can no longer be parameterized with either types.string or types.number. So instead of types.identifier() use types.identifier. Identifiers are now always normalized to strings. This reflects what was already happening internally and solves a lot of edge cases. To use numbers as identifiers, types.identifierNumber (instead of types.identifier(types.number)) can be used, which serializes it's snapshot to a number, but will internally work like a string based identifier
  • [BREAKING] types.maybe now serializes to / from undefined by default, as it is more and more the common best practice to don't use null at all and MST follows this practice. Use types.maybeNull for the old behavior (see #830)
  • [BREAKING] types.frozen is now a function, and can now be invoked in a few different ways:
    1. types.frozen() - behaves the same as types.frozen in MST 2.
    2. types.frozen(SubType) - provide a valid MST type and frozen will check if the provided data conforms the snapshot for that type. Note that the type will not actually be instantiated, so it can only be used to check the shape of the data. Adding views or actions to SubType would be pointless.
    3. types.frozen(someDefaultValue) - provide a primitive value, object or array, and MST will infer the type from that object, and also make it the default value for the field
    4. types.frozen<TypeScriptType>() - provide a typescript type, to help in strongly typing the field (design time only)
  • It is no longer necessary to wrap types.map or types.array in types.optional when used in a model type, map and array are now optional by default when used as property type. See #906
  • [BREAKING] postProcessSnapshot can no longer be declared as action, but, like preProcessSnapshot, needs to be defined on the type rather than on the instance.
  • [BREAKING] types.union is now eager, which means that if multiple valid types for a value are encountered, the first valid type is picked, rather then throwing. #907 / #804, dispatcher param => option,

Other improvements

  • [BREAKING] MobX-state-tree now requires at least TypeScript 2.8 when using MST with typescript. The type system has been revamped, and should now be a lot more accurate, especially concerning snapshot types.
  • [BREAKING] map.put will now return the inserted node, rather than the map itself. This makes it easier to find objects for which the identifier is not known upfront. See #766 by k-g-a
  • [BREAKING] The order of firing hooks when instantiating has slighlty changed, as the afterCreate hook will now only be fired upon instantiation of the tree node, which now happens lazily (on first read / action). The internal order in which hooks are fired within a single node has remained the same. See #845 for details
  • Significantly improved the performance of constructing MST trees. Significantly reduced the memory footprint of MST. Big shoutout to the relentless effort by k-g-a to optimize all the things! See #845 for details.
  • Introduced setLivelynessChecking("warn" | "ignore" | "error"), this can be used to customize how MST should act when one tries to read or write to a node that has already been removed from the tree. The default behavior is warn.
  • Improved the overloads of model.compose, see #892 by t49tran
  • Fixed issue where computed properties based on getPath could return stale results, fixes #917
  • Fixed issue where onAction middleware threw on dead nodes when attachAfter option was used
  • Fixed several issues with maps and numeric identifiers, such as #884 and #826

TL,DR Migration guide

  • types.identifier(types.number) => types.identifierNumber
  • types.identifier() and types.identifier(types.string) =>types.identifier
  • types.frozen => types.frozen()
  • types.maybe(x) => types.maybeNull(x)
  • postProcessSnapshot should now be declared on the type instead of as action
mweststrate
published 3.0.0-beta.2 •

mweststrate
published 2.2.0 •

Changelog

Source

2.2.0

  • Added support for MobX 5. Initiative by @jeffberry through #868. Please note that there are JavaScript engine restrictions for MobX 5 (no Internet Explorer, or React Native Android). If you need to target those versions please keep using MobX 4 as peer dependency (MST is compatible with both)
  • Reduced memory footprint with ~10-20%, by k-g-a through #872
  • Fixed issue where undo manager was not working correctly for non-root stores, by marcofugaro trough #875
mweststrate
published 2.1.0 •

Changelog

Source

2.1.0

  • Fixed issue where default values of types.frozen where not applied correctly after apply snapshot. #842 by SirbyAlive. Fixes #643
  • Fixed issue where empty patch sets resulted in in unnecessary history items. #838 by chemitaxis. Fixes #837
  • flows of destroyed nodes can no 'safely' resume. #798 by Bnaya. Fixes #792
  • Made sure the type Snapshot is exposed. #821 by dsabanin
  • Fix: the function parameter was incorrectly typed as non-optional. #851 by abruzzihraig
mweststrate
published 2.0.5 •

Changelog

Source

2.0.5

  • It is now possible to get the snapshot of a node without triggering the postProcessSnapshot hook. See #745 for details. By @robinfehr
  • Introduced getParentOfType and hasParentOfType. See #767 by @k-g-a
  • Fixed issue where running typeCheck accidentally logged typecheck errors to the console. Fixes #781
mweststrate
published 2.0.4-types.1 •

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc