setEvents method

void setEvents(
  1. DatabaseReference? ref
)

Implementation

void setEvents(DatabaseReference? ref) {
  if (ref == null) {
    return;
  }
  ref.once().then((DataSnapshot data) {
    for (final OnceCallback listener in _onceListeners) {
      listener(data);
    }
    //ignore: unnecessary_lambdas
  }).catchError((Object error) {
    setError(error);
  });

  _addedSubscription.add(ref.onChildAdded.listen((Event event) {
    for (final EventCallback listener in _addedListeners) {
      listener(event);
    }
  }, onError: (Object error, StackTrace stackTrace) {
    setError(error);
  }, onDone: () {
//      print('done');
  }));

  _removedSubscription.add(ref.onChildRemoved.listen((Event event) {
    for (final EventCallback listener in _removedListeners) {
      listener(event);
    }
  }, onError: (Object error, StackTrace stackTrace) {
    setError(error);
  }, onDone: () {
//      print('done');
  }));

  _changedSubscription.add(ref.onChildChanged.listen((Event event) {
    for (final EventCallback listener in _changedListeners) {
      listener(event);
    }
  }, onError: (Object error, StackTrace stackTrace) {
    setError(error);
  }, onDone: () {
//      print('done');
  }));

  _movedSubscription.add(ref.onChildMoved.listen((Event event) {
    for (final EventCallback listener in _movedListeners) {
      listener(event);
    }
  }, onError: (Object error, StackTrace stackTrace) {
    setError(error);
  }, onDone: () {
//      print('done');
  }));

  _valueSubscription.add(ref.onValue.listen((Event event) {
    for (final EventCallback listener in _valueListeners) {
      listener(event);
    }
  }, onError: (Object error, StackTrace stackTrace) {
    setError(error);
  }, onDone: () {
//      print('done');
  }));
}