chore(deps): Update dependency mobx to version .x 🌟 #4710
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
3.6.2
->4.12.0
Release Notes
mobxjs/mobx
v4.12.0
Compare Source
computedConfigurable
config #2011, #2013v4.11.0
Compare Source
BREAKING CHANGE
Reverted the support of Symbols in general in MobX 4, as it gives to many potential build errors and increases the system requirements for MobX 4 (which was an oversight in 4.10.0). Apologies for the breaking change (lack of new major version numbers). If lock files are properly used however, no harm should be caused by this change.
Symbol
support in observable maps and objects. Reverts #1944 through #1988. Fixes #1986, #1987v4.10.0
Compare Source
set
support forobservable.set
, see #1945 by xaviergonzv4.9.4
Compare Source
ObservableMap
, see #1930 by pimterrytoStringTag
for Maps and Sets, see #1929 by lennerdv4.9.3
Compare Source
observable.set
compatibility with IE 11, see #1917 by kalmiv4.9.2
Compare Source
Symbol
breaking Internet Explorer / React Native compatibility.v4.9.1
Compare Source
toJS
: observable maps were not properly serialized. Fixes #1875v4.9.0
Compare Source
Features
observable.box
now accepts anequals
option, to be able to pass a custom comparision function. Through #1862, #1874 by @fi3ework. Fixes #1580Fixes
flow
, see #1827 by @xaviergonztrace(true)
not being able to handle multi-line comments in traced function. Fixes #1850@computed
now introduces non-configurable properties, to fail fast on incorrect inheritance or property deletion. Fixes #1867enforceActions
andisolateGlobalState
now work correctly when used together. Fixes #1869v4.8.0
Compare Source
flow
in TypeScript 3. Fixes #1816 through #1825 by ismailhabibIGNORE_MOBX_MINIFIY_WARNING=true
to skip the built-in minification warning. See #1835 by fi3eworkv4.7.0
Compare Source
@computed
on a React component. The MobX 5 behavior here has been reverted to the MobX 4 behavior.v4.6.0
Compare Source
keepAlive
has become smarter and won't recomputed computed values that are kept alive, as long as they aren't read. Implements #1534undefined
was undetectedv4.5.2
Compare Source
toJS
not handlingnull
values correctly. Fixes #1557 through #1783 by @wangyiz4262v4.5.1
Compare Source
toJS
now has arecurseEverything
everything option, that even detects and converts observable objects that are "behind" non-observable objects. See #1699 by wangyiz4262comparer
, see #1751 by pdongv4.5.0
Compare Source
(Minor version of
5
was bumped significantly to make the number better correlate together :-))extendObservable
in a class constructor caused errors to be throwndelete
-ing a property was not always picked up by the reactivity systemremove()
-ing a property was not always picked up by thehas()
andget()
utilitieshas
now returnstrue
for computed fieldsget
now returns a value for computed fields_allowStateChangeInsideComputed
. Don't use it :-).v4.4.2
Compare Source
toString
does not behave correctly.v4.4.1
Compare Source
decorate
, see #1711 by makepostv4.4.0
Compare Source
configure({ isolateGlobalState: true })
. Note that this means that observables from the different MobX instances won't cooperate. Fixes #1681, #1082enforceActions
options now supports the values:"never"
,"observed"
and"always"
to make the behavior more clear. Fixes #1680, #1473v4.3.2
Compare Source
IAutorunOptions
decorate
now can apply multiple decorators, by accepting an array and applying them right to left:decorate(Todo, { title: [serializable(primitive), persist('object'), observable] })
. By @ramybenaroya through #1691 and #1686flow
so that it accepts async generators. By @dannsam through #1656 and #1655keys()
now also supports arrays. Fixes #1600 through #1601 by @nunocastromartinsv4.3.1
Compare Source
$mobx
export symbol for MobX 5 forward compatibityv4.3.0
Compare Source
entries(observable)
API, by @samjacobclift through #1536@computed({ set: ... })
wasn't picked upv4.2.1
Compare Source
mobx.configure
#1521 by @andrew--rmobx.flow
, fixes #1527@observable
in combination with a getter. #1511 by @quanganhtrantoJS
now uses Map internally, for faster detection of cycles. #1517 by @loathebobserve
hooks not being triggered when usingmobx.set
, Fixed in #1514 by @quanganhtranv4.2.0
Compare Source
configure({ enforceActions: "strict" })
, which is more strict thenenforceActions: true
, as it will also throw on non-observed changes to observables. See also #1473reaction
where not properly picked up by the global reaction systemObservableMap
, fixes #1496Symbol.toStringTag
(if available / polyfilled). This allows libraries like Ramda to detect automatically that observable arrays are arrays. Fixes #1490. Note thatArray.isArray
will keep returning false for the entire MobX 4 range.configurable
andwritable
, like in MobX 3. Fixes #1477fail
, by @mtaran-google through #1483 and #1482v4.1.1
Compare Source
default
from MobX will no longer throw, but only warn instead. This fixes some issues with tools that reflect on thedefault
export of a modulerunInAction
overload in the flow typings. #1451 by AMilassindecorate
. See #1450 by makepostv4.1.0
Compare Source
keepAlive
as option tocomputed
any
for their generic argumentsflow
cancellationwhen
is now automatically an action.@computed
properties are now declared on their owner rather then the protoptype. Fixes an issue where@computed
fields didn't work in React Native on proxied objects. See #1396action
andaction.bound
decorated fields are now reassignable, so that they can be stubbedv4.0.2
Compare Source
TypeError: Cannot define property:__mobxDidRunLazyInitializers, object is not extensible.
were thrown. Fixes #1404flow
, #1399 by @ismailhabibv4.0.1
Compare Source
v4.0.0
Compare Source
This is the extensive list of all changes.
New features
The changes mentioned here are discussed in detail in the release highlights, or were simply updated in the docs.
MobX 4 introduces separation between the production and non production build. The production build strips most typechecks, resulting in a faster and smaller build. Make sure to substitute process.env.NODE_ENV = "production" in your build process! If you are using MobX in a react project, you most probably already have set this up. Otherwise, the idea is explained here.
Introduced
flow
to create a chain of async actions. This is the same function asasyncActions
of the mobx-utils packageThese
flow
's are now cancellable, by calling.cancel()
on the returned promise, which will throw a cancellation exception into the generator function.flow
also has experimental support for async iterators (async * function
)Introduced
decorate(thing, decorators)
to decorate classes or object without needing decorator syntax.Introduced
onBecomeObserved
andonBecomeUnobserved
. These API's enable hooking into the observability system and get notified about when an observable starts / stops becoming used. This is great to automaticaly fetch data from external resources, or stop doing so.computed
/@computed
now accepts arequiresReaction
option. If it set, the computed value will throw an exception if it is being read while not being tracked by some reaction.To make
requiresReaction
the default, usemobx.configure({ computedRequiresReaction: true })
Introduced
mobx.configure({ disableErrorBoundaries })
, for easier debugging of exceptoins. By NaridaL through #1262toJS
now accepts the options:{ detectCycles?: boolean, exportMapsAsObjects?: boolean }
, bothtrue
by defaultObservable maps are now backed by real ES6 Maps. This means that any value can be used as key now, not just strings and numbers.
The flow typings have been updated. Since this is a manual effort, there can be mistakes, so feel free to PR!
computed(fn, options?)
/@computed(options) get fn()
now accept the following options:set: (value) => void
to set a custom setter on the computed propertyname: "debug name"
equals: fn
the equality value to use for the computed to determine whether its output has changed. The default iscomparer.default
. Alternatives arecomparer.structural
,comparer.identity
or just your own comparison function.requiresReaction: boolean
see above.autorun(fn, options?)
now accepts the following options:delay: number
debounce the autorun with the given amount of milliseconds. This replaces the MobX 3 apiautorunAsync
name: "debug name"
scheduler: function
a custom scheduler to run the autorun. For example to connect running the autorun torequestAnimationFrame
. See the docs for more detailsonError
. A custom error handler to be notified when an autorun throws an exception.reaction(expr, effect, options?)
now accepts the following options:delay: number
debounce the autorun with the given amount of milliseconds. This replaces the MobX 3 apiautorunAsync
fireImmediately
. Immediately fire the effect function after the first evaluation ofexpr
equals
. Custom equality function to determine whether theexpr
function differed from its previous result, and hence should fireeffect
. Accepts the same options as theequals
option of computed.autorun
acceptswhen(predicate, effect?, options?)
now accepts the following options:name: "debug name"
onError
. A custom error handler to be notified when an autorun throws an exception.timeout: number
a timeout in milliseconds, after which theonError
handler will be triggered to signal the condition not being met within a certain timeThe
effect
parameter ofwhen
has become optional. If it is omitted,when
will return a promise. This makes it easy toawait
a condition, for example:await when(() => user.profile.loaded)
. The returned promise can be cancelled usingpromise.cancel()
There is now an utility API that enables manipulating observable maps, objects and arrays with the same api. These api's are fully reactive, which means that even new property declarations can be detected by mobx if
set
is used to add them, andvalues
orkeys
to iterate them.values(thing)
returns all values in the collection as arraykeys(thing)
returns all keys in the collection as arrayset(thing, key, value)
orset(thing, { key: value })
Updates the given collection with the provided key / value pair(s).remove(thing, key)
removes the specified child from the collection. For arrays splicing is used.has(thing, key)
returns true if the collection has the specified observable property.get(thing, key)
returns the chlid under the specified key.observable
,observable.array
,observable.object
,observable.map
andextendObservable
now accept an additional options object, which can specify the following attributes:name: "debug name"
deep: boolean
.true
by default, indicates whether the children of this collection are automatically converted into observables as well.defaultDecorator: <decorator>
specifies the default decorator used for new children / properties, by default:observable.deep
, but could be changed toobservable.ref
,observable.struct
etc. (Thedeep
property is just a short-hand for switching betweenobservable.deep
orobservable.ref
as default decorator for new properties)Breaking changes
The changes mentioned here are discussed in detail in the migration notes
Map
to be globally available. Polyfill it if targeting IE < 11 or other older browsers.Map
and severalSymbol
s to exist for its typings. So make sure that thelib
configuration of your project is set to"es6"
. (The compilation target can still be"es5"
)observable.shallowArray(values)
has been removed, instead useobservable.array(values, { deep: false })
observable.shallowMap(values)
has been removed, instead useobservable.map(values, { deep: false })
observable.shallowObject(values)
has been removed, instead useobservable.object(values, {}, { deep: false })
extendShallowObservable(target, props)
, instead useextendObservable(target, props, {}, { deep: false })
observable.ref
,observable.shallow
,observable.deep
,observable.struct
can no longer be used as functions. Instead, they should be passed as part of thedecorators
param to resp.observable.object
andextendObservable
extendObservable
isextendObservable(target, props, decorators?, options?)
. This also means it is no longer possible to pass multiple bags of properties toextendObservable
.extendObservable
can no longer be used to re-declare properties. Useset
instead to update existing properties (or introduce new ones).map.values()
,map.entries()
,map.keys()
,map[@​@​iterator]()
andarray[@​@​iterator]()
no longer return an array, but an iterator. Usemobx.values(map)
orArray.from(map)
to convert the iterators to arrays.@computed.equals
, instead, you can now use@computed({ equals: ... })
useStrict(boolean)
was dropped, useconfigure({ enforceActions: boolean })
insteadisolateGlobalState
was dropped, useconfigure({ isolateGlobalState: true})
insteadshareGlobalState
feature. Instead, projects should be setup properly and it is up to the hosting package to make sure that there is only one MobX instanceexpr
has been moved to mobx-utils. Remember,expr(fn)
is justcomputed(fn).get()
createTransformer
has been moved to mobx-utilscontext
explicitly toautorun
,reaction
etc is no longer supported. Use arrow functions or function.bind instead.autorunAsync
. Use thedelay
option ofautorun
instead.autorun
,when
,reaction
don't support name as first argument anymore, instead pass thename
option.extras.
namespace has been dropped to enable tree-shaking non-used MobX features. All methods that where there originally are now exported at top level. If they are part of the official public API (you are encouraged to use them) they are exported as is. If they are experimental or somehow internal (you are discouraged to use them), they are prefixed with_
.spyReportStart
,spyReportEnd
,spyReport
andisSpyEnabled
are no longer public. It is no longer possible to emit custom spy events as to avoid confusing in listeners what the possible set of events is.isStrictModeEnabled
observable(value)
will only succeed if it can turn the value into an observable data structure (a Map, Array or observable object). But it will no longer create an observable box for other values to avoid confusion. Callobservable.box(value)
explictly in such cases.isComputed
andisObservable
no longer accept a property as second argument. Instead useisComputedProp
andisObservableProp
.whyRun
, usetrace
insteadAtom
class is no longer exposed. UsecreateAtom
instead (same signature).struct
andcompareStructural
for computed values are deprecated, use@computed.struct
orcomputed({ equals: comparer.structural})
instead.isModifierDescriptor
is no longer exposed.deepEqual
is no longer exposed, usecomparer.structural
instead.setReactionScheduler
->configure({ reactionScheduler: fn })
reserveArrayBuffer
->configure({ reactionErrorHandler: fn })
ObservableMap
is no longer exposed as constructor, useobservable.map
orisObservableMap
insteadmap
->observable.map
runInAction
no longer accepts a custom scopedefault
export that made it harder to tree-shake mobx. Make sure to always useimport { x } from "mobx"
and notimport mobx from "mobx"
.asFlat
etc. If you war still using this, see the MobX 2 -> 3 migration notes..move
methodobservable.deep.struct
modifierobservable.ref.struct
modifierobservable.struct
now behaves likeobservable.ref.struct
(this used to beobservable.deep.struct
). That is; values in anobservable.struct
field will be stored as is, but structural comparison will be used when assigning a new valueonError
option of reactions insteadIssues fixed in this release:
The issues are incoprorated in the above notes.
observable
apionBecomeObserved
&onBecomeUnobserved
onError
handler when creating reactionsobserve
Map
as backend implementation of observable mapsRenovate configuration
📅 Schedule: "before 3am on the first day of the month" in timezone America/New_York.
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻️ Rebasing: Whenever PR becomes conflicted, or if you modify the PR title to begin with "
rebase!
".🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Renovate Bot. View repository job log here.