This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
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:
^5.9.4
->^6.0.0
Release Notes
mobxjs/mobx
v6.0.0
Compare Source
New features
makeObservable(target, annotations)
is now the recommended way to make objects with a fixed shape observable, such as classes.makeAutoObservable(target)
will automatically determine the annotations used bymakeObservable
. Methods will be marked as 'autoAction', so that they can be used both from a computed value or as standalone method.observable.array
now supports{ proxy: false }
as option.reaction
's effect function now receives the previous value seen by the reaction as second argument.flow
can now be used as annotation as well. You might needflowResult
in case you use TypeScript to extract the correct result type. details.Breaking changes
Changes that might affect you
decorate
API has been removed, and needs to be replaced bymakeObservable
in the constructor of the targeted class. It accepts the same arguments. Themobx-undecorate
can transform this automatically.extendObservable
/observable
, fields that contained functions used to be turned into observables. This is no longer the case, they will be converted intoautoActions
.observed
mode.toJS
no longer takes any options. It no longer converts Maps and Sets to plain data structures. Generic, flexible serialization of data structures is out of scope for the MobX project, and writing custom serialization methods is a much more scalable approach to serialization (tip: leveragecomputed
s to define how class instances should be serialized).intercept
andobserve
are no longer exposed on observable arrays, maps and boxed observables. Import them as utility from mobx instead:import { observe, intercept } from "mobx"
, and pass the collection as first argument:observer(collection, callback)
. Note that we still recommend to avoid these APIs.observableMap.toPOJO()
,observableMap.toJS()
have been dropped. Usenew Map(observableMap)
instead if you want to convert an observable map to a plain Map shallowly.observableMap.toJSON()
now returns an entries array rather than a new Map, to better support serialization.observableSet.toJS()
has been dropped. Usenew Set(observableSet)
instead if you want to convert an observable Set to a plain Set shallowly.observableMap.toJSON()
now returns an array rather than a new Set, to better support serialization.isArrayLike
is no longer exposed as utility. UseArray.isArray(x) || isObservableArray(x)
instead.Obscure things that don't work anymore, but that probably won't affect you
@observable
ormakeObservable
) that is already declared in a super class.runInAction
no longer supports passing a name as first argument. Name the original function or useaction(name, fn)()
if you care about the debug name.computed(getterFn, setterFn)
no longer accepts a setter function as a second argument. Use theset
option instead:computed(getterFn, { set: setterFn })
.findIndex
/find
method, theoffset
argument (the third one) is no longer supported, to be consistent with ES arrays.computedConfigurable
ofconfigure
is no longer supported as it is now the default.observableArray.toJS()
has been removed, useobservableArray.slice()
instead, which does the same.IGNORE_MOBX_MINIFY_WARNING
environment flag._allowStateChangesInComputation(fn)
is no longer needed, userunInAction(fn)
instead.computed
, thewhen
predicate (first arg), andreaction
predicate (first arg) it is now forbidden to directly change state. State changes should be done in their effect functions, or otherwise at least wrapped inrunInAction
(only the state change, not the observables you want to track!). Note that this is still an anti-pattern.observableArray.get()
andobservableArray.set()
methods are no longer supported.IObservableObject
interface is no longer exported from MobX.reaction
effect function, the disposer object, is now passed in as third argument. The second argument is now the previous value seen by the reaction.onBecomeObserved
/onBecomeUnobserved
will now only trigger for observables that are actually used by a reaction (see #2309 for background).Fixes
this
for array callbacks such as inarray.forEach
array.concat
on(un)BecomeObserved
on(un)BecomeObserved
was triggered for observables changed in actions without having an observerRenovate configuration
📅 Schedule: At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻️ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.