PureMessageHandler

public class PureMessageHandler : MessageParser

A utility to parse RawMessages and call their attached handlers.

Handlers are functions that will be executed when handle(rawMessage: RawMessage) is called. Handlers are attached to a specific Message type for example: ProgramBusChanged.

  • Attaches a message handler to a concrete Message type. Every time a message of this type comes in, the provided handler will be called. The handler takes one generic argument message. The type of this argument indicates the type that this message handler will be attached to.

    Declaration

    Swift

    public func when<M>(_ handler: @escaping (_ message: M) -> Void) where M : DeserializableMessage

    Parameters

    handler

    The handler to attach

    message

    The message to which the handler is attached