drain method

  1. @Deprecated('Migrate to setListener instead. ' 'This feature was deprecated after v3.11.0-20.0.pre.')
Future<void> drain(
  1. String name,
  2. DrainChannelCallback callback
)

Deprecated. Migrate to setListener instead.

Remove and process all stored messages for a given channel.

This should be called once a channel is prepared to handle messages (i.e. when a message handler is set up in the framework).

The messages are processed by calling the given callback. Each message is processed in its own microtask.

Implementation

@Deprecated(
  'Migrate to setListener instead. '
  'This feature was deprecated after v3.11.0-20.0.pre.',
)
Future<void> drain(String name, DrainChannelCallback callback) async {
  final _Channel? channel = _channels[name];
  while (channel != null && !channel._queue.isEmpty) {
    final _StoredMessage message = channel.pop();
    await callback(message.data, message.invoke);
  }
}