Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/remove-legacy-apis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"mobx": major
"mobx-react-lite": patch
---

Removed a number of legacy APIs and their supporting internals.

Removed from `mobx`:

- The top-level object API: `get`, `set`, `has`, `remove`, `keys`, `values`, `entries`, `ownKeys`. Use the native/instance equivalents instead (e.g. `map.get()`, `[...map.keys()]`, `Object.keys(obj)`, `"key" in obj`, `delete obj.key`).
- The interception/observation APIs: `intercept`, `observe`, `_interceptReads`, and the `spy` API. Use `autorun`/`reaction` to react to changes.
- The introspection APIs: `getDebugName`, `getDependencyTree`, `getObserverTree`.
- The `dehancer` mechanism (used internally by the removed `_interceptReads`; it also backed some mobx-state-tree integrations, which are no longer supported).

All associated change-event interfaces (`I*WillChange` / `I*DidChange`), the `IInterceptable`/`IInterceptor`/`IListenable` interfaces, and the related internal machinery have been removed as well. The MobX devtools global hook (which depended on `spy`) has been removed. `MOBX_GLOBALS_VERSION` was bumped accordingly.

`mobx-react-lite` no longer wires the removed `getDependencyTree` into `React.useDebugValue`.
291 changes: 291 additions & 0 deletions API_REMOVAL_PLAN.md

Large diffs are not rendered by default.

86 changes: 0 additions & 86 deletions docs/analyzing-reactivity.md

This file was deleted.

98 changes: 0 additions & 98 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,20 +278,6 @@ _Utilities that might make working with observable objects or computed values mo

Attaches a global error listener, which is invoked for every error that is thrown from a _reaction_. This can be used for monitoring or test purposes.

### `intercept`

{🚀} Usage: `intercept(propertyName|array|object|Set|Map, listener)`
<small>(<b>[further information](intercept-and-observe.md#intercept)</b>)</small>

Intercepts changes before they are applied to an observable API. Returns a disposer function that stops the interception.

### `observe`

{🚀} Usage: `observe(propertyName|array|object|Set|Map, listener)`
<small>(<b>[further information](intercept-and-observe.md#observe)</b>)</small>

Low-level API that can be used to observe a single observable value. Returns a disposer function that stops the interception.

### `onBecomeObserved`

{🚀} Usage: `onBecomeObserved(observable, property?, listener: () => void)`
Expand Down Expand Up @@ -343,61 +329,6 @@ Use it to change how MobX behaves as a whole.

---

## Collection utilities {🚀}

_They enable manipulating observable arrays, objects and Maps with the same generic API._

### `values`

{🚀} Usage: `values(array|object|Set|Map)`
<small>(<b>[further information](collection-utilities.md)</b>)</small>

Returns all values in the collection as an array.

### `keys`

{🚀} Usage: `keys(array|object|Set|Map)`
<small>(<b>[further information](collection-utilities.md)</b>)</small>

Returns all keys / indices in the collection as an array.

### `entries`

{🚀} Usage: `entries(array|object|Set|Map)`
<small>(<b>[further information](collection-utilities.md)</b>)</small>

Returns a `[key, value]` pair of every entry in the collection as an array.

### `set`

{🚀} Usage: `set(array|object|Map, key, value)`
<small>(<b>[further information](collection-utilities.md)</b>)</small>

Updates the collection.

### `remove`

{🚀} Usage: `remove(array|object|Map, key)`
<small>(<b>[further information](collection-utilities.md)</b>)</small>

Removes item from the collection.

### `has`

{🚀} Usage: `has(array|object|Map, key)`
<small>(<b>[further information](collection-utilities.md)</b>)</small>

Checks for membership in the collection.

### `get`

{🚀} Usage: `get(array|object|Map, key)`
<small>(<b>[further information](collection-utilities.md)</b>)</small>

Gets value from the collection with key.

---

## Introspection utilities {🚀}

_Utilities that might come in handy if you want to inspect the internal state of MobX, or want to build cool tools on top of MobX._
Expand Down Expand Up @@ -462,34 +393,6 @@ Is this a boxed computed value, created using `computed(() => expr)`?

Is this a computed property?

### `spy`

{🚀} Usage: `spy(eventListener)`
<small>(<b>[further information](analyzing-reactivity.md#spy)</b>)</small>

Registers a global spy listener that listens to all events that happen in MobX.

### `getDebugName`

{🚀} Usage: `getDebugName(reaction|array|Set|Map)` or `getDebugName(object|Map, propertyName)`
<small>(<b>[further information](analyzing-reactivity.md#getdebugname)</b>)</small>

Returns the (generated) friendly debug name for an observable or reaction.

### `getDependencyTree`

{🚀} Usage: `getDependencyTree(object, computedPropertyName)`
<small>(<b>[further information](analyzing-reactivity.md#getdependencytree)</b>)</small>

Returns a tree structure with all observables the given reaction / computation currently depends upon.

### `getObserverTree`

{🚀} Usage: `getObserverTree(array|Set|Map)` or `getObserverTree(object|Map, propertyName)`
<small>(<b>[further information](analyzing-reactivity.md#getobservertree)</b>)</small>

Returns a tree structure with all reactions / computations that are observing the given observable.

---

## Extending MobX {🚀}
Expand All @@ -509,7 +412,6 @@ Creates your own observable data structure and hooks it up to MobX. Used interna
### `getAtom`

{🚀} Usage: `getAtom(thing, property?)`
<small>(<b>[further information](analyzing-reactivity.md#getatom)</b>)</small>

Returns the backing atom.

Expand Down
10 changes: 0 additions & 10 deletions docs/best/debugging-mobx.md

This file was deleted.

48 changes: 0 additions & 48 deletions docs/collection-utilities.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/computeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ This form of `computed` is not used very often, but in some cases where you need

### `name`

This string is used as a debug name in the [Spy event listeners](analyzing-reactivity.md#spy) and [MobX developer tools](https://github.com/mobxjs/mobx-devtools).
This string is used as a debug name in error messages and third-party developer tooling such as [mobx-log](https://github.com/kubk/mobx-log).

### `equals`

Expand Down
Loading