forked from reactiveui/ReactiveUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReactiveCollectionReusableView.cs
More file actions
113 lines (98 loc) · 3.77 KB
/
ReactiveCollectionReusableView.cs
File metadata and controls
113 lines (98 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Drawing;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Subjects;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading;
using ReactiveUI;
using Splat;
#if UNIFIED
using CoreGraphics;
using Foundation;
using UIKit;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
#endif
namespace ReactiveUI
{
public abstract class ReactiveCollectionReusableView : UICollectionReusableView,
IReactiveNotifyPropertyChanged<ReactiveCollectionReusableView>, IHandleObservableErrors, IReactiveObject, ICanActivate
{
#if UNIFIED
protected ReactiveCollectionReusableView(CGRect frame) : base(frame) { setupRxObj(); }
#else
protected ReactiveCollectionReusableView(RectangleF frame) : base(frame) { setupRxObj(); }
#endif
protected ReactiveCollectionReusableView() : base() { setupRxObj(); }
protected ReactiveCollectionReusableView(IntPtr handle) : base(handle) { setupRxObj(); }
protected ReactiveCollectionReusableView(NSObjectFlag t) : base(t) { setupRxObj(); }
protected ReactiveCollectionReusableView(NSCoder coder) : base(coder) { setupRxObj(); }
public event PropertyChangingEventHandler PropertyChanging;
void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args)
{
var handler = PropertyChanging;
if (handler != null) {
handler(this, args);
}
}
public event PropertyChangedEventHandler PropertyChanged;
void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args)
{
var handler = PropertyChanged;
if (handler != null) {
handler(this, args);
}
}
/// <summary>
/// Represents an Observable that fires *before* a property is about to
/// be changed.
/// </summary>
public IObservable<IReactivePropertyChangedEventArgs<ReactiveCollectionReusableView>> Changing {
get { return this.getChangingObservable(); }
}
/// <summary>
/// Represents an Observable that fires *after* a property has changed.
/// </summary>
public IObservable<IReactivePropertyChangedEventArgs<ReactiveCollectionReusableView>> Changed {
get { return this.getChangedObservable(); }
}
public IObservable<Exception> ThrownExceptions { get { return this.getThrownExceptionsObservable(); } }
void setupRxObj()
{
}
/// <summary>
/// When this method is called, an object will not fire change
/// notifications (neither traditional nor Observable notifications)
/// until the return value is disposed.
/// </summary>
/// <returns>An object that, when disposed, reenables change
/// notifications.</returns>
public IDisposable SuppressChangeNotifications()
{
return this.suppressChangeNotifications();
}
Subject<Unit> activated = new Subject<Unit>();
public IObservable<Unit> Activated { get { return activated; } }
Subject<Unit> deactivated = new Subject<Unit>();
public IObservable<Unit> Deactivated { get { return deactivated; } }
public override void WillMoveToSuperview(UIView newsuper)
{
base.WillMoveToSuperview(newsuper);
activated.OnNext(Unit.Default);
}
public override void RemoveFromSuperview()
{
base.RemoveFromSuperview();
deactivated.OnNext(Unit.Default);
}
}
}