trigger method

void trigger({
  1. required String eventName,
  2. required dynamic data,
})
inherited

Be careful with data.

In some cases pusher accepts double encoded data as String, in others - Map that will be encoded within the root object in PusherChannelsSentEventMixin.getEncoded.

See the implementation of: ChannelTriggerEvent.

Implementation

void trigger({
  required String eventName,
  required dynamic data,
}) {
  final event = ChannelTriggerEvent(
    channel: this,
    name: eventName,
    data: data,
  );
  if (state?.status != ChannelStatus.subscribed) {
    PusherChannelsPackageLogger.log(
      'Attempted to ChannelTriggerEvent "${event.name}" when Channel $name was not subscribed. Ignoring the attempt silently.',
    );
    return;
  }

  connectionDelegate.triggerEvent(event);
}