shouldSnapshot method

Future<bool> shouldSnapshot(
  1. StreamName name,
  2. TState state
)

Test if given state of stream name should be taken snapshot of

Implementation

Future<bool> shouldSnapshot(StreamName name, TState state) async {
  final snapshot = _states[name]?.state ?? await _read(name);
  return state.version > ExpectedStreamVersion.noStream.value &&
      (snapshot == null &&
              // Eager snapshot?
              (settings.eager || state.version > settings.threshold) ||
          snapshot != null &&
              // Threshold exceeded?
              (state.version - snapshot.version) > settings.threshold);
}