registerWithParent method

  1. @mustCallSuper
Future<void> registerWithParent(
  1. TypedSendPort<ChildIsolatePayload<LlamaResponse, LlamaCommand>> port
)
inherited

Registers this child with its parent.

This function is critical for establishing commmunication and should not be modified. If you need to run code when the isolate is spawned, prefer to override onSpawn instead. If you must override this, be sure to call super.registerWithParent() first.

Implementation

@mustCallSuper
Future<void> registerWithParent(
  TypedSendPort<ChildIsolatePayload<S, R>> port,
) async {
  _receiver = TypedReceivePort<R>(ReceivePort());
  _sender = port;
  _sender.send(
    ChildIsolateRegistration<S, R>(
      id: id,
      port: _receiver.sendPort,
    ),
  );
  await onSpawn();
  _receiver.stream.listen(onData);
}