when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String topic,
    2. String pairingTopic,
    3. Relay relay,
    4. int expiry,
    5. bool acknowledged,
    6. String controller,
    7. Map<String, Namespace> namespaces,
    8. ConnectionMetadata self,
    9. ConnectionMetadata peer,
    10. Map<String, RequiredNamespace>? requiredNamespaces,
    11. Map<String, RequiredNamespace>? optionalNamespaces,
    12. Map<String, String>? sessionProperties,
    13. List<Cacao>? authentication,
    14. TransportType transportType,
    )
)

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String topic,  String pairingTopic,  Relay relay,  int expiry,  bool acknowledged,  String controller,  Map<String, Namespace> namespaces,  ConnectionMetadata self,  ConnectionMetadata peer,  Map<String, RequiredNamespace>? requiredNamespaces,  Map<String, RequiredNamespace>? optionalNamespaces,  Map<String, String>? sessionProperties,  List<Cacao>? authentication,  TransportType transportType)  $default,) {final _that = this;
switch (_that) {
case _SessionData():
return $default(_that.topic,_that.pairingTopic,_that.relay,_that.expiry,_that.acknowledged,_that.controller,_that.namespaces,_that.self,_that.peer,_that.requiredNamespaces,_that.optionalNamespaces,_that.sessionProperties,_that.authentication,_that.transportType);}
}