EventTopicImpl.create constructor

EventTopicImpl.create({
  1. Type? type,
  2. String? nameType,
  3. String target = _targetDefault,
  4. String? path,
  5. String? fragment,
  6. String scheme = _shema,
  7. @Deprecated('Use scheme') String? shema,
  8. Map<String, String>? arguments,
})

Must required type or nameType

Implementation

EventTopicImpl.create(
    {Type? type,
    String? nameType,
    String target = _targetDefault,
    String? path,
    String? fragment,
    String scheme = _shema,
    @Deprecated('Use scheme') String? shema,
    Map<String, String>? arguments}) {
  if (type == null && nameType == null) {
    throw EventBusException('Topic.create required type or nameType !');
  }
  var typeName = '${type ?? nameType}'.replaceAll("?", "^");
  // the topic host is "target.type": a dot inside a part breaks parsing
  // and makes addresses collide (a.b.int is indistinguishable from a.int)
  assert(
      !target.contains('.') && !typeName.contains('.'),
      'Topic host must be "target.type": "target" and type name must not '
      'contain a dot (got "$target.$typeName")');
  _uri = Uri(
      scheme: shema ?? scheme,
      host: '$target.$typeName',
      path: path,
      fragment: fragment,
      queryParameters: arguments);
}