notify method

void notify(
  1. SSEResultState? state,
  2. dynamic data
)

used by a provider of features to tell the repository about updates to those features. If you were storing features on your device you could use this to fill the repository before it was connected for example.

Implementation

void notify(SSEResultState? state, dynamic data) {
  _log.fine('Data is $state -> $data');
  if (state != null) {
    switch (state) {
      case SSEResultState.ack:
        break;
      case SSEResultState.bye:
        _readynessState = Readyness.NotReady;
        if (!_catchAndReleaseMode) {
          _broadcastReadynessState();
        }
        break;
      case SSEResultState.failure:
        _readynessState = Readyness.Failed;
        if (!_catchAndReleaseMode) {
          _broadcastReadynessState();
        }
        break;
      case SSEResultState.features:
        final features = (data is List<FeatureState>)
            ? data
            : FeatureState.listFromJson(data);
        if (_hasReceivedInitialState && _catchAndReleaseMode) {
          _catchUpdatedFeatures(features);
        } else {
          var _updated = false;
          features.forEach((f) => _updated = _featureUpdate(f) || _updated);
          if (!_hasReceivedInitialState) {
            _checkForInvalidFeatures();
            _hasReceivedInitialState = true;
          } else if (_updated) {
            _triggerNewStateAvailable();
          }
          _readynessState = Readyness.Ready;
          _broadcastReadynessState();
        }
        break;
      case SSEResultState.feature:
        final feature = FeatureState.fromJson(data);
        if (_catchAndReleaseMode) {
          _catchUpdatedFeatures([feature]);
        } else {
          if (_featureUpdate(feature)) {
            _triggerNewStateAvailable();
          }
        }
        break;
      case SSEResultState.deleteFeature:
        _deleteFeature(FeatureState.fromJson(data));
        break;
    }
  }
}