Replies: 1 comment
-
here is another example https://github.com/Redth/FFImageLoading.Compat/blob/main/source/FFImageLoading.Maui/MauiExtensions.cs |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Many of the
ToPlatform()
type methods require a MauiContext. I see that objects don't have MauiContext set until they have their Handlers assigned. Handlers are assigned once the native objects have been set up and added to the hierarchy and are thus ready for Maui usage.Am I correct so far?
I think MauiContext is just some reference that is set through all Maui Handlers to let them talk back to the Maui App or shared other infrastructure. Ie. I think the MauiContext reference is the same for all objects always.
Is that correct too?
I see this summary which gives some clues:
https://github.com/dotnet/docs-maui/blob/main/docs/platform-integration/native-embedding.md
If so, and we know we have numerous functions needing
MauiContext
, what is the fastest way to get and store the reference to MauiContext (for example in a Singleton Instance)?My suspicion is the correct way to do this then is:
I presume the App must get its handler first and thus represents the first likely access to the MauiContext object? Is this correct or am I understanding this correctly?
Lastly, I have noted Handlers can change several times for some objects on startup (not sure why, haven't looked in detail and which ones off the top of my head), but is MauiContext expected to do the same?
Ie. Does MauiContext change over the App's lifespan? If we save a reference on startup is it good until the app restarts?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions