mobx-bonsai
Version:
A fast lightweight alternative to MobX-State-Tree + Y.js two-way binding
13 lines (11 loc) • 346 B
text/typescript
import { _getGlobalState } from "mobx"
/**
* Checks if we're currently inside a MobX action/batch/transaction.
* Uses MobX's global state to check the inBatch counter.
*
* @internal
* @returns true if inside any MobX action, batch, or transaction
*/
export function isInsideMobxAction(): boolean {
return _getGlobalState().inBatch > 0
}