- Introduction
- Introduction to Mobservable
- 2. Core API
- Advanced API
- Best Practices For Large Apps
- How does Mobservable work?
- Tips & Tricks
- 6.1. DevTools
- 6.2. ES5 / ES6 / TypeScript syntax
- 6.3. Tracking state changes
- 6.4. Performance considerations
- 7. Resources
- 8. Frequently Asked Questions
- Published with GitBook
Introduction
autorunUntil
autorunUntil(predicate: () => boolean, effect: () => void, scope?)
autorunUntil observes & runs the given predicate until it returns true. Once that happens, the given effect is executed and the autorunner is disposed. The function returns a disposer to cancel the autorunner prematurely.
This function is really useful to dispose or cancel stuff in a reactive way. For example:
class MyResource {constructor() {autorunUntil(// once...() => !this.isVisible,// ... then() => this.dispose());}@observable get isVisible() {// indicate whether this item is visible}dispose() {// dispose}}
