create method

HotlineSubscription create(
  1. dynamic channel, {
  2. Function? onReceived,
  3. Function? onConfirmed,
  4. Function? onUnsubscribed,
  5. Function? onRejected,
})

Create a new subscription to a channel, using a dynamic channel type to allow for simple String subscriptions or complex channels with parameters.

If using stream_for, with resource specific channels use {'channel': 'ChannelName', 'param': 1} alternatively if you're broadcasting via ActionCable.server.broadcast('ChannelName', {payload: ...}) and stream_from 'ChannelName' channel should be a string

Implementation

HotlineSubscription create(
    dynamic channel,
    {
      Function? onReceived,
      Function? onConfirmed,
      Function? onUnsubscribed,
      Function? onRejected
    })
{
  final identifier = _getChannelIdentifier(channel);
  final subscription = HotlineSubscription(
      identifier,
      this,
      onReceived: onReceived,
      onConfirmed: onConfirmed,
      onRejected: onRejected,
      onUnsubscribed: onUnsubscribed
  );

  _subscriptions.add(subscription);

  return subscription;
}