Event

public struct Event : EventInfoRecord, Encodable

An event to trigger on a specific Channel (or multiple channels).

  • The channels to which the event will be sent (if publishing to multiple channels).

    Declaration

    Swift

    public let channels: [Channel]?
  • The channel to which the event will be sent (if publishing to a single channel).

    Declaration

    Swift

    public let channel: Channel?
  • The event name.

    Declaration

    Swift

    public let name: String
  • This is the Data representation of the original data parameter of either of the init(...) methods. The data will be encrypted if a channel is set and its ChannelType is encrypted.

    Declaration

    Swift

    public let data: Data
  • A connection to which the event will not be sent.

    Declaration

    Swift

    public let socketId: String?

Lifecycle

  • Creates an event to be triggered on a specific Channel.

    Throws

    An PusherError if encoding the event data fails for some reason.

    Declaration

    Swift

    public init<EventData: Encodable>(name: String,
                                      data: EventData,
                                      channel: Channel,
                                      socketId: String? = nil,
                                      attributeOptions: ChannelAttributeFetchOptions = []) throws

    Parameters

    name

    The name of the event.

    data

    An event data object, whose type must conform to Encodable.

    channel

    The channel on which to trigger the event.

    socketId

    A connection to which the event will not be sent.

    attributeOptions

    A set of attributes that should be returned for the channel.

  • Creates an Event which will be triggered on multiple Channel instances.

    Throws

    An PusherError if encoding the event data fails for some reason, or if channels contains any encrypted channels.

    Declaration

    Swift

    public init<EventData: Encodable>(name: String,
                                      data: EventData,
                                      channels: [Channel],
                                      socketId: String? = nil,
                                      attributeOptions: ChannelAttributeFetchOptions = []) throws

    Parameters

    name

    The name of the event.

    data

    An event data object, whose type must conform to Encodable.

    channels

    An array of channels on which to trigger the event.

    socketId

    A connection to which the event will not be sent.

    attributeOptions

    A set of attributes that should be returned for each channel in channels.

Custom Encodable conformance