when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- Relay relay,
- Map<
String, Namespace> namespaces, - Map<
String, RequiredNamespace> ? requiredNamespaces, - Map<
String, RequiredNamespace> ? optionalNamespaces, - Map<
String, String> ? sessionProperties, - int expiry,
- 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);}
}