Skip to content

Commit

Permalink
Published version 5.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Mar 3, 2020
1 parent b87de4b commit b15d4c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions 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)
Expand Down
38 changes: 19 additions & 19 deletions README.md
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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",
Expand Down Expand Up @@ -96,4 +96,4 @@
"pre-commit": "lint-staged"
}
}
}
}

0 comments on commit b15d4c4

Please sign in to comment.