createNewInstancePair method
Create a new PairedInstance to be paired with instance
.
Also sends a message to another TypeChannelMessenger to instantiate an
object for TypeChannel with name: channelName
.
Returns null
if a pair with instance
has already been added to
messenger. Otherwise, it returns the paired PairedInstance.
Implementation
Future<PairedInstance?> createNewInstancePair(
String channelName,
Object instance,
List<Object?> arguments, {
required bool owner,
}) async {
if (isPaired(instance)) return null;
_addInstancePair(instance: instance, instanceId: null, owner: owner);
final PairedInstance pairedInstance = getPairedPairedInstance(instance)!;
await messageDispatcher.sendCreateNewInstancePair(
channelName,
pairedInstance,
converter.convertInstances(
instanceManager,
arguments,
)! as List<Object?>,
owner: !owner,
);
return pairedInstance;
}