Topic.parse constructor

Topic.parse(
  1. String str, {
  2. String separator = '.',
})

Parses an address built as <type><separator><path...>.

An empty type is rejected: a topic that no create can produce would never match a node.

Implementation

factory Topic.parse(String str, {String separator = '.'}) {
  var l = str.split(separator);
  if (l.isEmpty || l.first.isEmpty) {
    throw EventBusException('Cant parse topic $str');
  }
  return TopicImpl(l[0],
      paths: l.length > 1 ? l.sublist(1) : [], separator: separator);
}