when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. Relay relay,
    2. Map<String, Namespace> namespaces,
    3. Map<String, RequiredNamespace>? requiredNamespaces,
    4. Map<String, RequiredNamespace>? optionalNamespaces,
    5. Map<String, String>? sessionProperties,
    6. int expiry,
    7. ConnectionMetadata controller,
    )
)

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( Relay relay,  Map<String, Namespace> namespaces,  Map<String, RequiredNamespace>? requiredNamespaces,  Map<String, RequiredNamespace>? optionalNamespaces,  Map<String, String>? sessionProperties,  int expiry,  ConnectionMetadata controller)  $default,) {final _that = this;
switch (_that) {
case _WcSessionSettleRequest():
return $default(_that.relay,_that.namespaces,_that.requiredNamespaces,_that.optionalNamespaces,_that.sessionProperties,_that.expiry,_that.controller);}
}