diff --git a/docs/refguide/api.md b/docs/refguide/api.md index 040b5f5ad..5d4c30477 100644 --- a/docs/refguide/api.md +++ b/docs/refguide/api.md @@ -354,6 +354,7 @@ Returns a disposer function to cancel the side effect. - **`delay?: number`**: the sideEffect will be delayed and debounced with the given `delay`. Defaults to `0`. - **`onError?: (error) => void`**: error handler that will be triggered if the autorun function throws an exception - **`scheduler?: (callback) => void`**: Set a custom scheduler to determine how re-running the autorun function should be scheduled +- **`requiresObservable?: boolean`** Enables [`reactionRequiresObservable`](#reactionrequiresobservable-boolean) locally for the autorun ### `when` @@ -373,6 +374,7 @@ If no effect function is passed to `when`, it will return a promise that can be - **`name?: string`**: A name for easier identification and debugging - **`onError?: (error) => void`**: error handler that will be triggered if the _predicate-function_ or the _effect-function_ throws an exception - **`timeout: number`** a timeout in milliseconds, after which the `onError` handler will be triggered to signal the condition not being met within a certain time +- **`requiresObservable?: boolean`** Enables [`reactionRequiresObservable`](#reactionrequiresobservable-boolean) locally for the when ### `reaction` Usage: `reaction(() => data, data => { sideEffect }, options)`. @@ -388,6 +390,7 @@ The side effect can be debounced, just like `autorunAsync`. - **`delay?: number`**: the sideEffect will be delayed and debounced with the given `delay`. Defaults to `0`. - **`equals`**: Custom equality function to determine whether the expr function differed from it's previous result, and hence should fire effect. Accepts the same options as the equals option of `computed`. - Also accepts all of the options from [`autorun`](#autorun) +- **`requiresObservable?: boolean`** Enables [`reactionRequiresObservable`](#reactionrequiresobservable-boolean) locally for the reaction ### `onReactionError` @@ -525,6 +528,22 @@ Use this if you want to check whether you are using computed properties without configure({ computedRequiresReaction: true }); ``` +#### `observableRequiresReaction: boolean` +Warns about any unobserved observable access. +Use this if you want to check whether you are using observables without a reactive context (eg not inside an autorun, action, or react component without observer wrapping). + +```javascript +configure({ observableRequiresReaction: true }); +``` + +#### `reactionRequiresObservable: boolean` +Warns when a reaction (eg `autorun`) is created without any observable access. +Use this to check whether you are unneededly wrapping react components with `observer`, or to find possible related bugs. + +```javascript +configure({ reactionRequiresObservable: true }); +``` + #### `computedConfigurable: boolean` Allows overwriting computed values. This is useful for testing purposes *only*. Don't enable this on production as it can cause memory-leaks.