Great video! You really make it easy to understand how these things work. I was looking for how to use the old 'MessagingCenter' saw that it was deprecated, and then was like, "What the heck is this WeakReferenceMessenger??". Makes total sense now, thanks!
Wow, good to see that Microsoft embraced this essential feature. I am looking forward to trying it out in a Blazor app, where the communication between the different components is a key feature.
Hey James , this is a really good tutorial ! I followed your beginner series and have been having hard time to implement this myself. I think others may find this helpful, so it would be cool if you add it to the playlist as a final view Thanks for the video :)
You can actually use both! I'm also planning to investigate adding some IObservable APIs to the messenger types in the MVVM Toolkit, so one could easily get an observable representing a message subscription, to "bridge" the two worlds together and enable all sorts of other scenarios 🙂
Another great video. Thanks. Have you thought any more about a video demystifying Maui's csproj? Everytime anything gets added, another 20 lines show up in there! include, remove, update, etc LOL
I was scrambling all over the internet the last few days trying to understand how to actually use this feature on the toolkit... managed to understand a bit of the official documentation and its such a great feature, this video just helped me to further refine my usage of it. question though, I personally prefer having my commands in their own separate classes. Is there any way you'd recommend for me to go about it while making use of the mvvm toolkit?
Congrats on the 7 hour live stream. Unfortunately the docs don't click with me, I was also trying to understand how to use these Messages. I understand the concept of messages (subbing and unsubbing) from Unreal Engine. The toolkit is amazing, I don't know how to use it.
I am using it in WPF currently and it's really nice to decouple modules. 👍 Question: What's the reason to ensure the message is handled by the main thread?
Thanks for the video and great explanation. I just don't see in what scenario I would need to use the WeakReferenceMessenger in my application. Is it just to prevent the redundant code, or are there any other reasons to it? I mean I could have just put a RefreshList method on the page's OnAppear and I would get the main page content refreshed each time, so when I delete the item in other page I would still get the most recent collection when I navigate to my main page. So what is WeakReferenceMessenger good for?
Awesome content. I appreciate all you do. I do have a question. I’ve looked some and I can’t find any guidance on proper use of weak vs strong reference. If the toolkit exposes an improper way to use something, it will be used improperly. Again I appreciate your content.
Question: For this to work do you need to make sure that A) when using a DI tool that your Weak/Strong reference messenger is a singleton and B) that the recipient view model is also some form of singleton? I know in my early days working with this pattern I would wonder why things weren't working and it was due to the DI tool creating a new instance of things when it would resolve the view model type. Can't send messages between two things if those two things have two different instances of the messenger. I'm sure the "Default" property is static and so it wouldn't be noticed. Maybe the view models could still suffer the same fate if not registered in DI properly?
For A for sure singleton as it is used through the app and is already a singleton. For B it shouldn’t matter. The recipient will go away when not needed and will unregister if weak ref
Great video! A small question: What is the added value of using this ValueChangedMessage type because you can basically send any object of any type as a message.
I use mediatr in my apps - works great. I'm not a fan of inheriting from classes for messages, so using IRequest and INotification to indicate a response or not are great, and I get to use [record] for all my messages rather than a class.
Not quite "out of the box" exactly. I get that if you're using the Community Toolkit already it would make sense to give this a go over a dedicated implementation like MediatR, though.
I tried this today with pages that has transient dependency. Following this method had me trigger the same Receive method multiple times: say I enter to page and leave 5 times, if I trigger the Receive function; it will cause it to be triggered 5 times.
Thank you James. I just made use of this to pass a scanned QR Code value from a child ViewModel to its parent ViewModel, and it worked perfectly, updating the UI in the parent. Thanks also go to Gerald Versluis for his video about the ZXing scanning package.
Hello James Thanks for awesome video Can you make video on following topic 1. How can I implemented Jar binding in Maui. 2. How can I design UI for different screen size in xaml
Check out official docs for creating Java Bindings. The experience is not awesome and I really hope it gets better but you should be able to get through it if you learn the ropes well enough. For responsive UI, OnIdiom is the magic word. Check out how to use it
Thanks for your great videos. When would one use query properties in shell vs the messenger you mention here? Sounds like they both have similar capabilities to pass messages between view models.
@@JamesMontemagno Also, an identifier wouldn't be enough, you would probably also need to pass a "command" argument which should identify an action to be triggered...
James to Love to See a Video on Community Toolkit Messenger with DotNet Maui Dependency Injection, As Far as Community Toolkit Messenger Documentation there's no proper tutorial on implementing messenger with Dependency Injection, Love to see what you can regarding this
Hello thanks for your amazing videos, I have a .NET MAUI question, I am having an issue with the .NET MAUI Entry, Editor and Picker controls, They show without Underline or Bottom line in MAUI, do you know how to fix this for all platforms
Thanks for the video. However, I am trying to register a message using a specific token and cannot find any information on it. All I can find is how to unregister using a token. If you don't mind, can you provide information on this. Thanks
Hey James, it is now October 2022. I’m coming from Xam forms world and just getting started with my evaluation and exploration of Maui. One of the first things I encountered was an article from Microsoft about NOT using toolkit. Something about all that code being absorbed into Maui. Can you elaborate on this? All the early Maui videos rave about the community toolkit but now it appears as if that package is deprecated.
Why you used week manager? It is guaranteed that listener will not be randomly removed by by GC? It is safe used this week manager? Or what is the condition for removeng listneres from week variant?
You don't need to Unregister weak references; they auto get collected by the GC. So, in case of registering weak reference messenger you don't need to manually unregister it.
Hi it was very useful, I started my app migrate from Xamarin to .Net MAUI. I encounter few issues. 1. In android TabbedPage is showing blank page after login page, MFA page and tabbed dashboard. 2. Scroll view is not working when view loads and bing list cards from service. Page is not scrolling to show complete data loaded on page. 3. Community toolkit pop up size is not adjusting based on content and even scroll is not working. Could you help me to resolve the issue.
Thanks for showing this, but what happens if you're say 3 pages down and the first 2 pages are setup to listen for the delete message - when you delete the item on the 3rd page, will both pages get the command to delete?
Events between components would be a tight coupling in this example and with a messenger like this they are losely coupled and also have weak references that can be garbage collected easier
What kind of framework You using, what is that actually? You using visual studio code and C for android/mobile app? What about Android Studio? How it's working?
@@krccmsitp2884 yeah, 1. Prism does not require to override the constructor when you define your Event (Message). 2. When publish in Prism, you need just pass the payload (without explicit Event creation). 3. In Prism you don't need to register the recipient when subscribe. Just specify the Event type and pass payload if required.
@@yevheniytymchishin8401 Thanks for your answer, it's been quite along time since I used Prism. 1. You do not need to derive your message from ValueChangedMessage, the IMessenger implementations don't rely on it. 2. You must, however, derive your messages from PubSubEvent to get the magic, IIRC. 3. I don't see a conceptual difference between Subscribe() and Register(), after all you need to tell the messenger who will handle the message.
GoBack method is decorated with a relay command attribute. It is called when back button fires this command and I believe it takes you to the last page. I hope that helps.
Great video! You really make it easy to understand how these things work. I was looking for how to use the old 'MessagingCenter' saw that it was deprecated, and then was like, "What the heck is this WeakReferenceMessenger??". Makes total sense now, thanks!
Awesome! Glad you enjoyed it!
Great stuff! 👍🏻 Looking forward to more Toolkit 8.0.0 goodies!
Wow, good to see that Microsoft embraced this essential feature.
I am looking forward to trying it out in a Blazor app, where the communication between the different components is a key feature.
I learn a lot from your videos. I would like to see a video about background service with .NetMaui
Thanks
Hey James , this is a really good tutorial !
I followed your beginner series and have been having hard time to implement this myself.
I think others may find this helpful, so it would be cool if you add it to the playlist as a final view
Thanks for the video :)
Wow! Wow! Wow! This is exactly what I'm looking for! Many thanks!
As always, thank you! This has been supremely helpful!
Excellent James. Assume I could use this in a service, such as to listen to signalR pipeline messages. Then blast out messages within the app.
Enjoying all your content: Love the Breakdown and Usage!
I need a way of consistently using these toolkits in everyday code :D
This is super cool. Thanks James!
Pretty cool to see this used. I think I would still prefer the reactive extensions package for some use cases.
RX is my next exploration
You can actually use both! I'm also planning to investigate adding some IObservable APIs to the messenger types in the MVVM Toolkit, so one could easily get an observable representing a message subscription, to "bridge" the two worlds together and enable all sorts of other scenarios 🙂
Thank you James, Appreciate this!
Thank you for getting to the point right away. Liked and subscribed!
Thanks for the video, much better than the documentation!
Awesome as always James!
Another great video. Thanks. Have you thought any more about a video demystifying Maui's csproj? Everytime anything gets added, another 20 lines show up in there! include, remove, update, etc LOL
I was scrambling all over the internet the last few days trying to understand how to actually use this feature on the toolkit... managed to understand a bit of the official documentation and its such a great feature, this video just helped me to further refine my usage of it.
question though, I personally prefer having my commands in their own separate classes. Is there any way you'd recommend for me to go about it while making use of the mvvm toolkit?
Beautiful work
Congrats on the 7 hour live stream.
Unfortunately the docs don't click with me, I was also trying to understand how to use these Messages.
I understand the concept of messages (subbing and unsubbing) from Unreal Engine.
The toolkit is amazing, I don't know how to use it.
I am using it in WPF currently and it's really nice to decouple modules. 👍
Question: What's the reason to ensure the message is handled by the main thread?
Thanks for the video and great explanation. I just don't see in what scenario I would need to use the WeakReferenceMessenger in my application. Is it just to prevent the redundant code, or are there any other reasons to it? I mean I could have just put a RefreshList method on the page's OnAppear and I would get the main page content refreshed each time, so when I delete the item in other page I would still get the most recent collection when I navigate to my main page. So what is WeakReferenceMessenger good for?
smooth pub sub, ty for sharing
Awesome content. I appreciate all you do. I do have a question. I’ve looked some and I can’t find any guidance on proper use of weak vs strong reference. If the toolkit exposes an improper way to use something, it will be used improperly. Again I appreciate your content.
Question:
For this to work do you need to make sure that A) when using a DI tool that your Weak/Strong reference messenger is a singleton and B) that the recipient view model is also some form of singleton?
I know in my early days working with this pattern I would wonder why things weren't working and it was due to the DI tool creating a new instance of things when it would resolve the view model type. Can't send messages between two things if those two things have two different instances of the messenger. I'm sure the "Default" property is static and so it wouldn't be noticed. Maybe the view models could still suffer the same fate if not registered in DI properly?
For A for sure singleton as it is used through the app and is already a singleton. For B it shouldn’t matter. The recipient will go away when not needed and will unregister if weak ref
Great video! A small question: What is the added value of using this ValueChangedMessage type because you can basically send any object of any type as a message.
What's the difference compared to Mediatr and why should I use Messenger instead? Thanks in advance!
Never used mediatr will check it out
I use mediatr in my apps - works great.
I'm not a fan of inheriting from classes for messages, so using IRequest and INotification to indicate a response or not are great, and I get to use [record] for all my messages rather than a class.
Its a Mediatr pattern out from the box. Its really useful
Not quite "out of the box" exactly. I get that if you're using the Community Toolkit already it would make sense to give this a go over a dedicated implementation like MediatR, though.
It's an simple Event or Message Dispatcher. Or others know that as EventAggregator or what ever. It's trivial and old.
Great video. Thanks! Is there a way to be a recipient of two or three different messages?
Very cool. And thanks for your videos. What about the garbage collector? Do I have to explicitly unregister subscriber?
RTFM. Sorry. StrongReferenceMessenger vs. WeakReferenceMessenger. 👍🏻
Strong ref yes, weak no as it is weak and will get collected
You're the best!
Was looking for this so much... We had EventAggregator in Prism which was missing on MAUI
잘보고 있습니다. 감사합니다.
I tried this today with pages that has transient dependency. Following this method had me trigger the same Receive method multiple times: say I enter to page and leave 5 times, if I trigger the Receive function; it will cause it to be triggered 5 times.
Thank you James. I just made use of this to pass a scanned QR Code value from a child ViewModel to its parent ViewModel, and it worked perfectly, updating the UI in the parent. Thanks also go to Gerald Versluis for his video about the ZXing scanning package.
Hey, how do you implemented the navigation for the parent vm once you moved to the child viewmode?
@@CuongNguyen-gu9fl Sorry, I moved to Flutter just after that and stopped all work in MAUI and have no recollection of this now.
Hello James Thanks for awesome video
Can you make video on following topic
1. How can I implemented Jar binding in Maui.
2. How can I design UI for different screen size in xaml
Check out official docs for creating Java Bindings. The experience is not awesome and I really hope it gets better but you should be able to get through it if you learn the ropes well enough. For responsive UI, OnIdiom is the magic word. Check out how to use it
Your videos are great!
Can you do a demo showing how to display local notifications on the phone using MAUI? (e.g. SnackBar)
Thanks for your great videos. When would one use query properties in shell vs the messenger you mention here? Sounds like they both have similar capabilities to pass messages between view models.
Depends. Like here I could have popped via “..” and then passed some info, but what if I’m not navigating you know
Just another tool in the toolbox
@@JamesMontemagno Also, an identifier wouldn't be enough, you would probably also need to pass a "command" argument which should identify an action to be triggered...
Awesome exploration, but in the minute 8:48 the r stands for the recipient not for the sender -_-
Good catch!
Does not Maui already have MessagingCenter that does the same job?
Yes, but it's deprecated. It seems that it's something of a resource hog.
James to Love to See a Video on Community Toolkit Messenger with DotNet Maui Dependency Injection, As Far as Community Toolkit Messenger Documentation there's no proper tutorial on implementing messenger with Dependency Injection, Love to see what you can regarding this
Channels. You are welcome.
great video!!
Please show us how to use TToken to send and receive messages
Would not it be better if you use Observables from System.Reactive ?
I might be wrong but I don't think you need to register it in constructor if you use IRecipient
항상 고맙소
Hello thanks for your amazing videos, I have a .NET MAUI question, I am having an issue with the .NET MAUI Entry, Editor and Picker controls, They show without Underline or Bottom line in MAUI, do you know how to fix this for all platforms
how about a multiple IRecipient? seems like MessagingCenter Send and Subscribe right?
Yes!!! That is the goal to do multiple!! I think of this as messaging center replacement
@@JamesMontemagno wow that's cool! it refactors my messaging center.
Thanks for the video. However, I am trying to register a message using a specific token and cannot find any information on it. All I can find is how to unregister using a token. If you don't mind, can you provide information on this. Thanks
I would suggest opening an issue on the projects GitHub page. That is usually the fastest
@@JamesMontemagno Thanks, but I finally figured it out for myself.
What if Delete was async i.e. async Task Delete(string text);?
Hey James, it is now October 2022. I’m coming from Xam forms world and just getting started with my evaluation and exploration of Maui. One of the first things I encountered was an article from Microsoft about NOT using toolkit. Something about all that code being absorbed into Maui. Can you elaborate on this? All the early Maui videos rave about the community toolkit but now it appears as if that package is deprecated.
There is a new toolkit for .net Maui, so you want to transition to that one
Why you used week manager? It is guaranteed that listener will not be randomly removed by by GC? It is safe used this week manager? Or what is the condition for removeng listneres from week variant?
You don't need to Unregister weak references; they auto get collected by the GC. So, in case of registering weak reference messenger you don't need to manually unregister it.
Hi it was very useful, I started my app migrate from Xamarin to .Net MAUI. I encounter few issues.
1. In android TabbedPage is showing blank page after login page, MFA page and tabbed dashboard.
2. Scroll view is not working when view loads and bing list cards from service. Page is not scrolling to show complete data loaded on page.
3. Community toolkit pop up size is not adjusting based on content and even scroll is not working. Could you help me to resolve the issue.
Hard to help over comments on TH-cam. I would open issues in the respective github repo and try to create a new project to recreate something smaller.
Thanks for showing this, but what happens if you're say 3 pages down and the first 2 pages are setup to listen for the delete message - when you delete the item on the 3rd page, will both pages get the command to delete?
Anyone that is subscribed would get the message correct so you should know who/what is subscribing to events.
@@JamesMontemagno Great thanks for confirming, thought that might be the case.
How to explicitly unregister the recipients🧐
Is there source generator varinat for this feature? Any attribut or something?
Thanks! Sorry if this is a daft question but how does this compare with subscribing to events? (E.g. performance diffs, convenience)
Events between components would be a tight coupling in this example and with a messenger like this they are losely coupled and also have weak references that can be garbage collected easier
@@JamesMontemagno Thanks!
awesome
How can I implement this in an asynchronous way?
What kind of framework You using, what is that actually?
You using visual studio code and C for android/mobile app? What about Android Studio?
How it's working?
Check out all my videos on .NET MAUI! iOS android Mac and windows cross platform in c# with visual studio
What is the difference between this pub-sub messenger and the .net maui mesasging center ?
I would say that this is a much improved version over the built in one IMHO
Your camera seems to be acting strangely. You can see banding moving across the background and the framerate seems low.
Hmmm i'll take a look at it.
i have a question plz i need respons if .net maui can execute ussd command if there any documentation for that i need that for my project plz tell me
Video request: Media Picker (CapturePhotoAsync) with Winui3 patch fix.
Llevo 1.5 años en .net con c# y el manejo de James es tan alto que no entiendo la mitad de lo que escribe.
I wish Prism pub sub was available in all .net apps not just Wpf
how add event Click to ContentView in maui
I would add a TapGestureRecognizer for this :) it can be added to any view
This seems like an EventAggregator pattern with weak and strong references. It's nice but I don't see it being such a big deal.
public event EventHandler Clicked;
public event EventHandler Pressed;
public event EventHandler Released;
Thank you Jesus looking man 👞
I absolutely love the hair and beard. Pure eyecandy.
he was keeping saying "WeakReferenceManager"
I like Prism approach more.
Could you elaborate a bit on on that, please?
@@krccmsitp2884 yeah,
1. Prism does not require to override the constructor when you define your Event (Message).
2. When publish in Prism, you need just pass the payload (without explicit Event creation).
3. In Prism you don't need to register the recipient when subscribe. Just specify the Event type and pass payload if required.
@@yevheniytymchishin8401 Thanks for your answer, it's been quite along time since I used Prism.
1. You do not need to derive your message from ValueChangedMessage, the IMessenger implementations don't rely on it.
2. You must, however, derive your messages from PubSubEvent to get the magic, IIRC.
3. I don't see a conceptual difference between Subscribe() and Register(), after all you need to tell the messenger who will handle the message.
👍
I guess this would be too easy
[ObservableProperty]
[SendMessageOnMainThread(DeleteItemMessage)]
private string deletedMessage;
What is this await GoBack(); does.
GoBack method is decorated with a relay command attribute. It is called when back button fires this command and I believe it takes you to the last page. I hope that helps.
It just navigates back to the previous page. When he clicks the Delete button, see how it leaves the detail page and goes back to the menu page
Thanks