• Runs the given function in an action, i.e. when there are no active subscribers. This is useful for making changes to reactive items without triggering subscribers.

    Parameters

    • fn: Function

      The function to be run in an action.

    Returns void

    Example

    let a = atom(0, { name: "a" });
    let b = atom(0, { name: "b" });

    let count = 0;

    a.subscribe(() => {
    count++;
    runInAction(() => {
    b.value = a.value;
    });
    });

    a.value++;
    console.log(a.value, b.value, count); // 1 1 1