onBatch property

  1. @override
LxOnBatch? get onBatch
override

Intercepts and optionally wraps a batch execution.

Implementation

@override
LxOnBatch? get onBatch => (next, change) {
      return () {
        if (_isRestoring) return next();
        _batchDepth++;
        try {
          return next();
        } finally {
          _batchDepth--;
          if (_batchDepth == 0 && change.isNotEmpty) _addChange(change);
        }
      };
    };