Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 1cb9857

Browse files
committed
Added ViewModelBase class.
And make all VMs inherit from this instead of directly from `ReactiveObject`.
1 parent a3f270f commit 1cb9857

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/GitHub.App/GitHub.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<Reference Include="WindowsBase" />
133133
</ItemGroup>
134134
<ItemGroup>
135+
<Compile Include="ViewModels\ViewModelBase.cs" />
135136
<None Include="..\..\script\Key.snk" Condition="$(Buildtype) == 'Internal'">
136137
<Link>Key.snk</Link>
137138
</None>

src/GitHub.App/ViewModels/DialogViewModelBase.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
using System.Windows.Input;
2-
using ReactiveUI;
3-
using NullGuard;
4-
using GitHub.UI;
5-
using System;
1+
using System;
62
using System.Reactive;
73
using GitHub.Extensions.Reactive;
4+
using NullGuard;
5+
using ReactiveUI;
86

97
namespace GitHub.ViewModels
108
{
119
/// <summary>
1210
/// Base class for view models that can be dismissed, such as dialogs.
1311
/// </summary>
14-
public abstract class DialogViewModelBase : ReactiveObject, IDialogViewModel, IHasBusy
12+
public abstract class DialogViewModelBase : ViewModelBase, IDialogViewModel, IHasBusy
1513
{
1614
protected ObservableAsPropertyHelper<bool> isShowing;
1715
string title;
@@ -51,10 +49,5 @@ public bool IsBusy
5149

5250
/// <inheritdoc/>
5351
IObservable<Unit> IHasCancel.Cancel => Cancel.SelectUnit();
54-
55-
/// <inheritdoc/>
56-
public virtual void Initialize([AllowNull] ViewWithData data)
57-
{
58-
}
5952
}
6053
}

src/GitHub.App/ViewModels/PanePageViewModelBase.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace GitHub.ViewModels
77
/// <summary>
88
/// Base class for view models that appear as a page in a navigable pane, such as the GitHub pane.
99
/// </summary>
10-
public class PanePageViewModelBase : ReactiveObject, IPanePageViewModel
10+
public class PanePageViewModelBase : ViewModelBase, IPanePageViewModel
1111
{
1212
string title;
1313

@@ -25,10 +25,5 @@ public string Title
2525
get { return title; }
2626
protected set { this.RaiseAndSetIfChanged(ref title, value); }
2727
}
28-
29-
/// <inheritdoc/>
30-
public virtual void Initialize([AllowNull] ViewWithData data)
31-
{
32-
}
3328
}
3429
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using GitHub.UI;
3+
using NullGuard;
4+
using ReactiveUI;
5+
6+
namespace GitHub.ViewModels
7+
{
8+
/// <summary>
9+
/// Base class for view models.
10+
/// </summary>
11+
public abstract class ViewModelBase : ReactiveObject, IViewModel
12+
{
13+
/// <inheritdoc/>
14+
public virtual void Initialize([AllowNull] ViewWithData data)
15+
{
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)