ThumperBloc<E> constructor

ThumperBloc<E>(
  1. Iterable<E> _iterable,
  2. Iterator<E> _iterator,
  3. Spectrum _spectrum,
  4. Stream<bool> _timerFactoryFunc(
    1. Frequency
    ),
  5. int autoThumpLimit,
  6. Logger _log,
)

ThumperBloc accepts

  • A non-empty Iterable
  • A non-empty _iterator derived from the iterable.
  • A Spectrum of allowed thumper frequency values.
  • A factory func that accepts a frequency and returns a Stream
  • A limit to automatic thumping. Hitting it automatically pauses.

Implementation

ThumperBloc(
  this._iterable,
  this._iterator,
  this._spectrum,
  this._timerFactoryFunc,
  this.autoThumpLimit,
  this._log,
)   : assert(_iterable.isNotEmpty, 'iterable cannot be empty'),
      assert(
          _iterator.current != null, ' iterator must have a current value'),
      assert(autoThumpLimit > 0, 'autoThumpLimit must be > 0'),
      _autoThumpsRemaining = autoThumpLimit,
      super(ThumperState.init(
        _iterator.current,
        Frequency(_spectrum, 0),
      )) {
  on<ThumperEventResumed>(_onResumed);
  on<ThumperEventPaused>(_onPaused);
  on<ThumperEventDecreased>(_onDecreased);
  on<ThumperEventIncreased>(_onIncreased);
  on<ThumperEventThumpedAutomatically>(_onThumpedAutomatically);
  on<ThumperEventThumpedManually>(_onThumpedManually);
  on<ThumperEventRewound>(_onRewound);
}