[Home] > Reference
KAMISHIBAI supports event notification when Page display status is changed.
Not page navigation event, the state of the pages is changed.
Even in the case of switching between Tab and CarouselPage, KAMISHIBAI will notifies consistent events.
Event notifications are made for the Page or View Model that implements the corresponding interface (such as IPageInitializeAware).
Event notifications are executed recursively from the parent Page to the child Page.
The actual notification target and the order of notification depend on the type of event and the Page type.
Notify event type is as follows:
There is also a next interface to receive all events.
- IPageLifecycleAware
- IPageLifecycleAware<in TParam>
| Explanation | |
|---|---|
| Overview | It is notified only once to the newly created Page and ViewModel at the Page navigation. It is assumed to be used for the implementation of the initialization process. If a parameter is specified, it can be received. Only OnInitialize events can receive parameters. Before the navigation process is executed (for example, before calling the INavigation#Pusyasync() method). Not be notified, if you came back in return. |
| Interface | IPageInitializeAware、IPageInitializeAware<in TParam> |
| Basic notification order | Be notified before the screen transitions. Notify parent to child with top down. Notify Page ahead of ViewModel. |
| MasterDetailPage notification order | 1. MasterDetailPage 2. MasterPage 3. DetailPage. |
| NavigationPage notification order | 1. Navigationpage 2. NavigationStack ascending |
| TabbedPage notification order | 1. TabbedPage 2. Tabs Ascending |
| CarouselPage notification order | 1. CarouselPage 2. Child Page Ascending |
| Explanation | |
|---|---|
| Overview | It is notified after displaying the Page. (PushAsync, etc.) not only when forward, but also when returned in some way back processing is notified. OnUnload, designed to be Page deactivation, OnLoaded assumes activation process in reverse. Supposed to come back in a physical back button and swipe. Therefore, it does not correspond to parameters. |
| Interface | IPageLoadedAware |
| Basic notification order | After displaying a page, ago the original Page's OnUnload notified. From parent to child to notify top-down. Notify ViewModel after notifying page. |
| MasterDetailPage notification order | 1. MasterDetailPage 2. MasterPage 3. DetailPage. |
| NavigationPage notification order | 1. NavigationPage 2. Current Page |
| TabbedPage notification order | 1. TabbedPage 2. Current Tab Page |
| CarouselPage notification order | 1. CarouselPage 2. Current Page |
| Explanation | |
|---|---|
| Overview | It is notified after Page is not displayed. Expects the implementation of Page deactivation process. It is notified to Page that may be redisplayed. Page that pops from the stack will be notified of onclosed. |
| Interface | IPageUnloadedAware |
| Basic notification order | It is notified after OnLoaded is notified to the displayed Page. From child to parent to notify buttom-up. Notify Page after notifying View Model. |
| MasterDetailPage notification order | 1. DetailPage 2. MasterPage 3. MasterDetailPage |
| NavigationPage notification order | 1. Current Page 2. NavigationPage |
| TabbedPage notification order | 1. Current Tab Page 2. TabbedPage When there are multiple tabs, the hidden tab is not notified. Also notified when the tab is hidden from display. |
| CarouselPage notification order | 1. Current Page 2. CarouselPage When there are multiple Pages, the hidden page is not notified. Also notified when the Page is hidden from display. |
| 説明 | |
|---|---|
| Overview | Notified when the Page is destroyed. If the page is pop from the stack, etc. It is intended to release resources and unsubscribe from events. |
| Interface | IPageClosedAware |
| Basic notification order | It is notified after OnLoaded is notified to the displayed Page. From child to parent to notify buttom-up. Notify Page after notifying View Model. |
| MasterDetailPage notification order | 1. DetailPage 2. MasterPage 3. MasterDetailPage |
| NavigationPage notification order | 1. NavigationPage 2. NavigationStack Descending |
| TabbedPage notification order | 1. TabbedPage 2. All Tabs Descending |
| CarouselPage notification order | 1. CarouselPage 2. All Child Pages Descending |
KAMISHIBAI is the Page Navigation library. Originally dealing with application life-cycle events is not might be appropriate.
However, the mechanism for notifying Application OnSleep and OnResume will be similar to the KAMISHIBAI notification.
For this reason, KAMISHIBAI provides a mechanism for notifying application lifecycle events.
For notifications, implement the following in the Onsleep and Onresume of the App.cs class:
protected override void OnSleep()
{
LifecycleNoticeService.OnSleep(this);
}
protected override void OnResume()
{
LifecycleNoticeService.OnResume(this);
}| 説明 | |
|---|---|
| Overview | To notify the OnSleep of the Xamarin.Forms.Application |
| Interface | IApplicationLifecycleAware |
| Basic notification order | Notify all Pages and View Models. Notify all pages on ModalStack in descending order, then notify MainPage. If the page on the modalstack has a nested structure, from child to parent to notify buttom-up. Notify Page after notifying View Model. |
| MasterDetailPage notification order | 1. DetailPage 2. MasterPage 3. MasterDetailPage |
| NavigationPage notification order | 1. NavigationPage 2. NavigationStack Descending |
| TabbedPage notification order | 1. TabbedPage 2. All Tabs Descending |
| CarouselPage notification order | 1. CarouselPage 2. All Child Pages Descending |
| 説明 | |
|---|---|
| Overview | To notify the OnResume of the Xamarin.Forms.Application |
| Interface | IApplicationLifecycleAware |
| Basic notification order | Notify all Pages and View Models. Notify MainPage, then notify all pages on ModalStack in ascending order. If the page on the modalstack has a nested structure, from parent to child to notify top-down. Notify Page after notifying View Model. |
| MasterDetailPage notification order | 1. MasterDetailPage 2. MasterPage 3. DetailPage. |
| NavigationPage notification order | 1. NavigationPage 2. NavigationStack Ascending |
| TabbedPage notification order | 1. TabbedPage 2. Tabs Ascending |
| CarouselPage notification order | 1. CarouselPage 2. Child Page Ascending |
Kamishibai can pass a type-safe parameter.
To pass parameters, implement the following:
- Navigation request by using INavigationRequest<in TParam>
- Page or View Model to implement IPageInitializeAware<in TParam> or IPageLifecycleAware<in TParam>
If you pass a parameter of type string, you request navigation as follows:
public INavigationRequest<string> RequestNavigation { get; } = new NavigationRequest<string>();
public Task Navigation()
{
return RequestNavigation.RaiseAsync("param");
}And, it receives it as follows:
public FooPageViewModel : IPageInitializeAware<string>
{
public void OnInitialize(string parameter)
{
...
}
}There is no problem even if the type parameter of the interface and the parameter passed are different. But it must be assignable to the receiving side.
Also, if you pass a parameter on a navigation request, you will not receive a notification in IPageInitializeAware without a type parameter.