when<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- 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,
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);}
}