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

Commit 19d6e6f

Browse files
committed
Move CancelCommand to BaseViewModel.
From `PullRequestCreationViewModel`. Added `CancelCommand` to new interface `IReactiveViewModel` and make `BaseViewModel` implement that.
1 parent c649e0a commit 19d6e6f

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

src/GitHub.App/ViewModels/BaseViewModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55

66
namespace GitHub.ViewModels
77
{
8-
public class BaseViewModel : ReactiveObject, IViewModel
8+
public class BaseViewModel : ReactiveObject, IReactiveViewModel
99
{
1010
protected ObservableAsPropertyHelper<bool> isShowing;
1111

12+
public BaseViewModel()
13+
{
14+
CancelCommand = ReactiveCommand.Create();
15+
}
16+
1217
public ReactiveCommand<object> CancelCommand { get; protected set; }
1318
public ICommand Cancel { get { return CancelCommand; } }
1419

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
using GitHub.Exports;
2-
using NullGuard;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.ComponentModel.Composition;
6-
using System.Globalization;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading.Tasks;
10-
using ReactiveUI;
1+
using System.ComponentModel.Composition;
2+
using GitHub.Exports;
113

124
namespace GitHub.ViewModels
135
{
146
[ExportViewModel(ViewType = UIViewType.PRCreation)]
157
[PartCreationPolicy(CreationPolicy.NonShared)]
168
class PullRequestCreationViewModel : BaseViewModel, IPullRequestCreationViewModel
179
{
18-
public PullRequestCreationViewModel()
19-
{
20-
CancelCommand = ReactiveCommand.Create();
21-
}
2210
}
2311
}

src/GitHub.Exports.Reactive/GitHub.Exports.Reactive.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
<Compile Include="ViewModels\IPullRequestCreationViewModel.cs" />
103103
<Compile Include="ViewModels\IPullRequestDetailViewModel.cs" />
104104
<Compile Include="ViewModels\IPullRequestListViewModel.cs" />
105+
<Compile Include="ViewModels\IReactiveViewModel.cs" />
105106
<Compile Include="ViewModels\IRepositoryCreationTarget.cs" />
106107
<Compile Include="ViewModels\IRepositoryForm.cs" />
107108
<Compile Include="ViewModels\IRepositoryPublishViewModel.cs" />

src/GitHub.Exports.Reactive/ViewModels/IPullRequestCreationViewModel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
namespace GitHub.ViewModels
44
{
55
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
6-
public interface IPullRequestCreationViewModel : IViewModel
6+
public interface IPullRequestCreationViewModel : IReactiveViewModel
77
{
8-
ReactiveCommand<object> CancelCommand { get; }
98
}
109
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using ReactiveUI;
2+
3+
namespace GitHub.ViewModels
4+
{
5+
public interface IReactiveViewModel : IViewModel
6+
{
7+
ReactiveCommand<object> CancelCommand { get; }
8+
}
9+
}

0 commit comments

Comments
 (0)