Skip to content

Commit a45a716

Browse files
committed
Move implementation of INotifyPropertyChanged in another class
1 parent ced98b5 commit a45a716

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

src/FreshMvvm/FreshBasePageModel.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
using System;
2-
using System.ComponentModel;
3-
using System.Threading.Tasks;
42
using Xamarin.Forms;
5-
using System.Runtime.CompilerServices;
63

74
namespace FreshMvvm
85
{
9-
public abstract class FreshBasePageModel : INotifyPropertyChanged
10-
{
11-
public event PropertyChangedEventHandler PropertyChanged;
12-
6+
public abstract class FreshBasePageModel : FreshNotifyPropertyChanged
7+
{
138
/// <summary>
149
/// The previous page model, that's automatically filled, on push
1510
/// </summary>
@@ -41,14 +36,6 @@ public virtual void Init (object initData)
4136
{
4237
}
4338

44-
protected void RaisePropertyChanged ([CallerMemberName] string propertyName = null)
45-
{
46-
var handler = PropertyChanged;
47-
if (handler != null) {
48-
handler (this, new PropertyChangedEventArgs (propertyName));
49-
}
50-
}
51-
5239
internal void WireEvents (Page page)
5340
{
5441
page.Appearing += ViewIsAppearing;

src/FreshMvvm/FreshMvvm.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -31,6 +31,7 @@
3131
<ConsolePause>false</ConsolePause>
3232
</PropertyGroup>
3333
<ItemGroup>
34+
<Compile Include="FreshNotifyPropertyChanged.cs" />
3435
<Compile Include="Properties\AssemblyInfo.cs" />
3536
<Compile Include="FreshBasePageModel.cs" />
3637
<Compile Include="FreshIOC.cs" />
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.ComponentModel;
2+
using System.Runtime.CompilerServices;
3+
4+
namespace FreshMvvm
5+
{
6+
public abstract class FreshNotifyPropertyChanged : INotifyPropertyChanged
7+
{
8+
public event PropertyChangedEventHandler PropertyChanged;
9+
10+
protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
11+
{
12+
var handler = PropertyChanged;
13+
if (handler != null)
14+
{
15+
handler(this, new PropertyChangedEventArgs(propertyName));
16+
}
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)