: https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/messaging-center/
Simple String Message
The simplest message contains just a string in the
message
parameter. A Subscribe
method that listens for a simple string message is shown below - notice the generic type specifying the sender is expected to be of type MainPage
. Any classes in the solution can subscribe to the message using this syntax:MessagingCenter.Subscribe<MainPage> (this, "Hi", (sender) => {
// do something whenever the "Hi" message is sent
});
In the
MainPage
class the following code sends the message. The this
parameter is an instance of MainPage
.MessagingCenter.Send<MainPage> (this, "Hi");
The string doesn't change - it indicates the message type and is used for determining which subscribers to notify. This sort of message is used to indicate that some event occurred, such as "upload completed", where no further information is required.
하지만 뭐든지 남용하는 건 안될 것 같다.
다음은 MessagingCenter를 사용하지 않아도 될 부분들을 정리해 놓은 내용이다.
Misuses Of MessagingCenter
: https://xamarinhelp.com/common-misuse-messagingcenter/
하지만 뭐든지 남용하는 건 안될 것 같다.
다음은 MessagingCenter를 사용하지 않아도 될 부분들을 정리해 놓은 내용이다.
Misuses Of MessagingCenter
: https://xamarinhelp.com/common-misuse-messagingcenter/
댓글 없음:
댓글 쓰기