subscribe<T> method

StreamSubscription<T> subscribe<T>(
  1. String topic,
  2. void onData(
    1. T
    )
)

Subscribe to a topic.

Implementation

StreamSubscription<T> subscribe<T>(String topic, void Function(T) onData) {
  return _streamController.stream
      .where((msg) => msg.topic == topic /*&& msg.data is T*/)
      .map((msg) => msg.data as T)
      .listen((event) {
    if ( Tracer.enabled)
      Tracer.trace("editor.bus", TraceLevel.high, " deliver '$topic', event=$event");

    onData(event);
  });
}