IMessenger.Register<TRecipient,TMessage,TToken> Method

Definition

Registers a recipient for a given type of message.

public void Register<TRecipient,TMessage,TToken> (TRecipient recipient, TToken token, CommunityToolkit.Mvvm.Messaging.MessageHandler<TRecipient,TMessage> handler) where TRecipient : class where TMessage : class where TToken : IEquatable<TToken>;
abstract member Register : 'Recipient * 'oken * CommunityToolkit.Mvvm.Messaging.MessageHandler<'Recipient, 'Message (requires 'Recipient : null and 'Message : null)> -> unit (requires 'Recipient : null and 'Message : null and 'oken :> IEquatable<'oken>)
Public Sub Register(Of TRecipient As Class, TMessage As Class, TToken As Class) (recipient As TRecipient, token As TToken, handler As MessageHandler(Of TRecipient, TMessage))

Type Parameters

TRecipient

The type of recipient for the message.

TMessage

The type of message to receive.

TToken

The type of token to use to pick the messages to receive.

Parameters

recipient
TRecipient

The recipient that will receive the messages.

token
TToken

A token used to determine the receiving channel to use.

handler
MessageHandler<TRecipient,TMessage>

The MessageHandler<TRecipient,TMessage> to invoke when a message is received.

Exceptions

Thrown when trying to register the same message twice.

Applies to