Skip to content

Commit

Permalink
Merge branch 'feature/updated-lifecycle-events' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstonis committed Aug 10, 2023
2 parents 1b583da + afa4f59 commit 715a796
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Stellar.Blazor/ComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ public abstract class ComponentBase<TViewModel> : ReactiveComponentBase<TViewMod
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new BlazorViewManager();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> IsAppearing => ViewManager.IsAppearing;

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
{
}
Expand Down
10 changes: 10 additions & 0 deletions Stellar.Blazor/InjectableComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ public abstract class InjectableComponentBase<TViewModel> : ReactiveInjectableCo
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new BlazorViewManager();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> IsAppearing => ViewManager.IsAppearing;

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
{
}
Expand Down
10 changes: 10 additions & 0 deletions Stellar.Blazor/LayoutComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ public abstract class LayoutComponentBase<TViewModel> : ReactiveLayoutComponentB
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new BlazorViewManager();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> IsAppearing => ViewManager.IsAppearing;

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
{
}
Expand Down
4 changes: 4 additions & 0 deletions Stellar.Maui/Pages/ContentPageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class ContentPageBase<TViewModel> : ReactiveContentPage<TViewMod
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class ContentPageBase<TViewModel> : ReactiveContentPage<TViewMod

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
4 changes: 4 additions & 0 deletions Stellar.Maui/Pages/FlyoutPageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class FlyoutPageBase<TViewModel> : ReactiveMasterDetailPage<TVie
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class FlyoutPageBase<TViewModel> : ReactiveMasterDetailPage<TVie

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
4 changes: 4 additions & 0 deletions Stellar.Maui/Pages/MultiPageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public abstract class MultiPageBase<TPage, TViewModel> : ReactiveMultiPage<TPage
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -19,6 +21,8 @@ public abstract class MultiPageBase<TPage, TViewModel> : ReactiveMultiPage<TPage

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
4 changes: 4 additions & 0 deletions Stellar.Maui/Pages/NavigationPageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class NavigationPageBase<TViewModel> : ReactiveNavigationPage<TV
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class NavigationPageBase<TViewModel> : ReactiveNavigationPage<TV

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
4 changes: 4 additions & 0 deletions Stellar.Maui/Pages/TabbedPageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class TabbedPageBase<TViewModel> : ReactiveTabbedPage<TViewModel
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class TabbedPageBase<TViewModel> : ReactiveTabbedPage<TViewModel

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
8 changes: 8 additions & 0 deletions Stellar.Maui/Views/ContentViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class ContentViewBase<TViewModel> : ReactiveContentView<TViewMod
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class ContentViewBase<TViewModel> : ReactiveContentView<TViewMod

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down Expand Up @@ -60,6 +64,8 @@ public abstract class ContentViewBase<TViewModel, TDataModel> : ReactiveContentV
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -68,6 +74,8 @@ public abstract class ContentViewBase<TViewModel, TDataModel> : ReactiveContentV

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
4 changes: 4 additions & 0 deletions Stellar.Maui/Views/FrameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class FrameBase<TViewModel> : ReactiveFrame<TViewModel>, IStella
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class FrameBase<TViewModel> : ReactiveFrame<TViewModel>, IStella

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
8 changes: 8 additions & 0 deletions Stellar.Maui/Views/GridBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class GridBase<TViewModel> : ReactiveGrid<TViewModel>, IStellarV
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class GridBase<TViewModel> : ReactiveGrid<TViewModel>, IStellarV

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down Expand Up @@ -61,6 +65,8 @@ public abstract class GridBase<TViewModel, TDataModel> : ReactiveGrid<TViewModel
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -69,6 +75,8 @@ public abstract class GridBase<TViewModel, TDataModel> : ReactiveGrid<TViewModel

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
8 changes: 8 additions & 0 deletions Stellar.Maui/Views/StackLayoutBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class StackLayoutBase<TViewModel> : ReactiveStackLayout<TViewMod
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class StackLayoutBase<TViewModel> : ReactiveStackLayout<TViewMod

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down Expand Up @@ -61,6 +65,8 @@ public abstract class StackLayoutBase<TViewModel, TDataModel> : ReactiveGrid<TVi
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -69,6 +75,8 @@ public abstract class StackLayoutBase<TViewModel, TDataModel> : ReactiveGrid<TVi

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
8 changes: 8 additions & 0 deletions Stellar.Maui/Views/ViewCellBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public abstract class ViewCellBase<TViewModel> : ReactiveViewCell<TViewModel>, I
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -18,6 +20,8 @@ public abstract class ViewCellBase<TViewModel> : ReactiveViewCell<TViewModel>, I

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down Expand Up @@ -61,6 +65,8 @@ public abstract class ViewCellBase<TViewModel, TDataModel> : ReactiveViewCell<TV
[EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager { get; } = new MauiViewManager<TViewModel>();

public IObservable<Unit> Initialized => ViewManager.Initialized;

public IObservable<Unit> Activated => ViewManager.Activated;

public IObservable<Unit> Deactivated => ViewManager.Deactivated;
Expand All @@ -69,6 +75,8 @@ public abstract class ViewCellBase<TViewModel, TDataModel> : ReactiveViewCell<TV

public IObservable<Unit> IsDisappearing => ViewManager.IsDisappearing;

public IObservable<Unit> Disposed => ViewManager.Disposed;

public IObservable<LifecycleEvent> Lifecycle => ViewManager.Lifecycle;

public virtual void Initialize()
Expand Down
4 changes: 2 additions & 2 deletions Stellar/Extensions/IStellarViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void InitializeStellarComponent<TViewModel>(
stellarView.ViewManager.RegisterBindings(stellarView);
}

stellarView.ViewManager.OnLifecycle(LifecycleEvent.Loaded);
stellarView.ViewManager.OnLifecycle(LifecycleEvent.Initialized);
}

public static void ManageDispose<TViewModel>(this IStellarView<TViewModel> stellarView, bool disposing, ref bool isDisposed)
Expand All @@ -51,7 +51,7 @@ public static void ManageDispose<TViewModel>(this IStellarView<TViewModel> stell

if (disposing)
{
stellarView.ViewManager.OnLifecycle(LifecycleEvent.Unloaded);
stellarView.ViewManager.OnLifecycle(LifecycleEvent.Disposed);

stellarView.ViewManager?.Dispose();
stellarView.DisposeViewModel();
Expand Down
4 changes: 2 additions & 2 deletions Stellar/LifecycleEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
public enum LifecycleEvent
{
Unknown = 0,
Loaded = 1,
Initialized = 1,
Activated = 2,
IsAppearing = 3,
IsDisappearing = 4,
Deactivated = 5,
Unloaded = 6,
Disposed = 6,
}
4 changes: 4 additions & 0 deletions Stellar/ViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public abstract class ViewManager : IDisposable

private bool _isDisposed;

public IObservable<Unit> Initialized => _lifecycle.Value.Where(x => x == LifecycleEvent.Initialized).SelectUnit().AsObservable();

public IObservable<Unit> Activated => _lifecycle.Value.Where(x => x == LifecycleEvent.Activated).SelectUnit().AsObservable();

public IObservable<Unit> Deactivated => _lifecycle.Value.Where(x => x == LifecycleEvent.Deactivated).SelectUnit().AsObservable();
Expand All @@ -23,6 +25,8 @@ public abstract class ViewManager : IDisposable

public IObservable<Unit> IsDisappearing => _lifecycle.Value.Where(x => x == LifecycleEvent.IsDisappearing).SelectUnit().AsObservable();

public IObservable<Unit> Disposed => _lifecycle.Value.Where(x => x == LifecycleEvent.Disposed).SelectUnit().AsObservable();

public IObservable<LifecycleEvent> Lifecycle => _lifecycle.Value.AsObservable();

public bool Maintain { get; set; }
Expand Down

0 comments on commit 715a796

Please sign in to comment.