publicChannel method

PublicChannel publicChannel(
  1. String channelName, {
  2. bool forceCreateNewInstance = false,
})

Creates a public channel.

Note: if forceCreateNewInstance is true then this client will return a new instance each time this method is called instead of giving an internally linked one.

Example:

var oldVariable = client.publicChannel('hello');
var newVariable = client.publicChannel('hello');
// prints true
print(oldVariable == newVariable);
var newestVariable = client.publicChannel(
  'hello',
  forceCreateNewInstance: true,
// prints false
print(newestVariable == oldVariable || newestVariable == newVariable);

Implementation

/// var newestVariable = client.publicChannel(
///   'hello',
///   forceCreateNewInstance: true,
// );

/// // prints false
/// print(newestVariable == oldVariable || newestVariable == newVariable);
/// ```
PublicChannel publicChannel(
  String channelName, {
  bool forceCreateNewInstance = false,
}) {
  if (_isDisposed) {
    throw const PusherChannelsClientDisposedException();
  }
  return channelsManager.publicChannel(
    channelName,
    forceCreateNewInstance: forceCreateNewInstance,
  );
}