diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d08301..f57b710 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 5.5.5 + +* Fixed tree-shaking mobx-utils, see [#238](https://github.com/mobxjs/mobx-utils/pull/238) by [IgorBabkin](https://github.com/IgorBabkin) + # 5.5.4 * Fix invalid `actionAsync` context when promises resolve at the same time in different actionAsync calls, by [xaviergonz](https://github.com/xaviergonz) through [#240](https://github.com/mobxjs/mobx-utils/pull/240) diff --git a/README.md b/README.md index 4dca54c..4d8fefa 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ This is useful to replace one promise based observable with another, without goi ```javascript @observer class SearchResults extends React.Component { - @observable.ref searchResults + @observable searchResults componentDidUpdate(nextProps) { if (nextProps.query !== this.props.query) @@ -465,46 +465,46 @@ Returns **IDisposer** disposer function that can be used to cancel the when prem ## keepAlive -MobX normally suspends any computed value that is not in use by any reaction, -and lazily re-evaluates the expression if needed outside a reaction while not in use. -`keepAlive` marks a computed value as always in use, meaning that it will always fresh, but never disposed automatically. - ### Parameters - `_1` - `_2` -- `target` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object that has a computed property, created by `@computed` or `extendObservable` -- `property` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the property to keep alive +- `computedValue` **IComputedValue<any>** created using the `computed` function ### Examples ```javascript -const obj = observable({ - number: 3, - doubler: function() { return this.number * 2 } -}) -const stop = keepAlive(obj, "doubler") +const number = observable(3) +const doubler = computed(() => number.get() * 2) +const stop = keepAlive(doubler) +// doubler will now stay in sync reactively even when there are no further observers +stop() +// normal behavior, doubler results will be recomputed if not observed but needed, but lazily ``` Returns **IDisposer** stops this keep alive so that the computed value goes back to normal behavior ## keepAlive +MobX normally suspends any computed value that is not in use by any reaction, +and lazily re-evaluates the expression if needed outside a reaction while not in use. +`keepAlive` marks a computed value as always in use, meaning that it will always fresh, but never disposed automatically. + ### Parameters - `_1` - `_2` -- `computedValue` **IComputedValue<any>** created using the `computed` function +- `target` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** an object that has a computed property, created by `@computed` or `extendObservable` +- `property` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the property to keep alive ### Examples ```javascript -const number = observable(3) -const doubler = computed(() => number.get() * 2) -const stop = keepAlive(doubler) -// doubler will now stay in sync reactively even when there are no further observers -stop() -// normal behavior, doubler results will be recomputed if not observed but needed, but lazily +const obj = observable({ + number: 3, + doubler: function() { return this.number * 2 } +}) +const stop = keepAlive(obj, "doubler") ``` Returns **IDisposer** stops this keep alive so that the computed value goes back to normal behavior diff --git a/package.json b/package.json index b13bdf6..93c64b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobx-utils", - "version": "5.5.4", + "version": "5.5.5", "description": "Utility functions and common patterns for MobX", "main": "mobx-utils.umd.js", "module": "lib/mobx-utils.js", @@ -96,4 +96,4 @@ "pre-commit": "lint-staged" } } -} +} \ No newline at end of file