HubCategoryBehavior

public protocol HubCategoryBehavior

Behavior of the Hub category that clients will use

  • Dispatch a Hub message on the specified channel

    Declaration

    Swift

    func dispatch(to channel: HubChannel, payload: HubPayload)

    Parameters

    channel

    The channel to send the message on

    payload

    The payload to send

  • Listen to Hub messages with a particular event name on a particular channel

    Declaration

    Swift

    func listen(to channel: HubChannel,
                eventName: HubPayloadEventName,
                listener: @escaping HubListener) -> UnsubscribeToken

    Parameters

    channel

    The channel to listen for messages on

    eventName

    Only hub payloads with this event name will be dispatched to the listener

    listener

    The closure to invoke with the received message

  • Listen to Hub messages on a particular channel, optionally filtering message prior to dispatching them

    Declaration

    Swift

    func listen(to channel: HubChannel,
                isIncluded filter: HubFilter?,
                listener: @escaping HubListener) -> UnsubscribeToken

    Parameters

    channel

    The channel to listen for messages on

    filter

    If specified, candidate messages will be passed to this closure prior to dispatching to the listener. Only messages for which the filter returns true will be dispatched.

    listener

    The closure to invoke with the received message

  • Removes the listener identified by token

    Declaration

    Swift

    func removeListener(_ token: UnsubscribeToken)

    Parameters

    token

    The UnsubscribeToken returned by listen

  • publisher(for:) Extension method

    Returns a publisher for all Hub messages sent to channel

    Declaration

    Swift

    public func publisher(for channel: HubChannel) -> HubPublisher

    Parameters

    channel

    The channel to listen for messages on