com.fofx.observething 1.1.0 → 1.1.1-dev.161
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Runtime/{Operators/IInitializationOperationsProvider.cs → IInitializationOperationsProvider.cs} +1 -1
- package/Runtime/{IObservable.cs → Observables/IObservable.cs} +13 -9
- package/Runtime/{Implementations/ObservableBase.cs → Observables/Observable.cs} +6 -19
- package/Runtime/{Implementations → Observables}/ObservableCollection.cs +6 -15
- package/Runtime/{Implementations → Observables}/ObservableDictionary.cs +7 -18
- package/Runtime/{Implementations/Observable.cs → Observables/ObservableEventStream.cs} +11 -3
- package/Runtime/{Implementations → Observables}/ObservableList.cs +3 -13
- package/Runtime/{Implementations → Observables}/ObservableSet.cs +6 -15
- package/Runtime/{Implementations → Observables}/ObservableValue.cs +4 -11
- package/Runtime/Observables.meta +1 -1
- package/Runtime/ObservationDefaults.cs +10 -0
- package/Runtime/ObservationDefaults.cs.meta +2 -0
- package/Runtime/Observers.cs +51 -64
- package/Runtime/Operators/BatchOperator.cs +52 -51
- package/Runtime/Operators/BatchOperator.cs.meta +1 -1
- package/Runtime/{Observables/CastObservable.cs → Operators/CastOperator.cs} +10 -10
- package/Runtime/{Observables/CombineObservable.cs → Operators/CombineOperator.cs} +10 -10
- package/Runtime/{Observables/CombineValueObservable.cs → Operators/CombineValueOperator.cs} +12 -12
- package/Runtime/{Observables/ConcatObservable.cs → Operators/ConcatOperator.cs} +2 -2
- package/Runtime/{Observables/ContainsObservable.cs → Operators/ContainsOperator.cs} +2 -2
- package/Runtime/Operators/ContainsOperator.cs.meta +2 -0
- package/Runtime/{Observables/CountObservable.cs → Operators/CountOperator.cs} +2 -2
- package/Runtime/{Observables/DistinctObservable.cs → Operators/DistinctOperator.cs} +2 -2
- package/Runtime/Operators/{CollectionOperator.cs → Factories/CollectionOperatorFactory.cs} +2 -9
- package/Runtime/Operators/{DictionaryOperator.cs → Factories/DictionaryOperatorFactory.cs} +2 -9
- package/Runtime/Operators/{ObservableOperator.cs → Factories/EventStreamOperatorFactory.cs} +17 -10
- package/Runtime/Operators/{ListOperator.cs → Factories/ListOperatorFactory.cs} +2 -9
- package/Runtime/Operators/{Operator.cs → Factories/OperatorFactory.cs} +8 -8
- package/Runtime/Operators/{SetOperator.cs → Factories/SetOperatorFactory.cs} +2 -9
- package/Runtime/Operators/{ValueOperator.cs → Factories/ValueOperator.cs} +2 -9
- package/Runtime/{Implementations.meta → Operators/Factories.meta} +1 -1
- package/Runtime/{Observables/FirstObservable.cs → Operators/FirstOperator.cs} +2 -2
- package/Runtime/{Observables/IndexOfObservable.cs → Operators/IndexOfOperator.cs} +2 -2
- package/Runtime/Operators/OperationStreamOperator.cs +212 -0
- package/Runtime/{Observables.cs → Operators/Operators.cs} +105 -73
- package/Runtime/{Observables/OrderByObservable.cs → Operators/OrderByOperator.cs} +2 -2
- package/Runtime/{Observables/SelectCollectionObservable.cs → Operators/SelectCollectionOperator.cs} +2 -2
- package/Runtime/{Observables/SelectListObservable.cs → Operators/SelectListOperator.cs} +2 -2
- package/Runtime/{Observables/SelectManyObservable.cs → Operators/SelectManyOperator.cs} +2 -2
- package/Runtime/{Observables/SkipWhileObservable.cs → Operators/SkipWhileOperator.cs} +2 -2
- package/Runtime/{Observables/ThenObservable.cs → Operators/ThenOperator.cs} +2 -2
- package/Runtime/{Observables/ToDictionaryObservable.cs → Operators/ToDictionaryOperator.cs} +3 -3
- package/Runtime/{Observables/TrackObservable.cs → Operators/TrackOperator.cs} +2 -2
- package/Runtime/{Observables/UnwrapCollectionObservable.cs → Operators/UnwrapCollectionOperator.cs} +2 -2
- package/Runtime/{Observables/UnwrapListObservable.cs → Operators/UnwrapListOperator.cs} +2 -2
- package/Runtime/{Observables/UnwrapValueObservable.cs → Operators/UnwrapValueOperator.cs} +2 -2
- package/Runtime/{Observables/WhereObservable.cs → Operators/WhereOperator.cs} +2 -2
- package/Runtime/{Observables/WithPreviousObservable.cs → Operators/WithPreviousOperator.cs} +2 -2
- package/Tests/CollectionObservableTests.cs +1 -1
- package/Tests/DictionaryObservableTests.cs +1 -1
- package/Tests/ListObservableTests.cs +1 -1
- package/Tests/ObservationContextTests.cs +109 -83
- package/Tests/ValueObservableTests.cs +1 -1
- package/package.json +5 -4
- package/Runtime/Observables/BatchObservable.cs +0 -72
- package/Runtime/Observables/BatchObservable.cs.meta +0 -2
- package/Runtime/Observables/ContainsObservable.cs.meta +0 -2
- package/Runtime/Observables/OperationStreamObservable.cs +0 -194
- /package/Runtime/{Operators/IInitializationOperationsProvider.cs.meta → IInitializationOperationsProvider.cs.meta} +0 -0
- /package/Runtime/{IObservable.cs.meta → Observables/IObservable.cs.meta} +0 -0
- /package/Runtime/{Implementations/ObservableBase.cs.meta → Observables/Observable.cs.meta} +0 -0
- /package/Runtime/{Implementations → Observables}/ObservableCollection.cs.meta +0 -0
- /package/Runtime/{Implementations → Observables}/ObservableDictionary.cs.meta +0 -0
- /package/Runtime/{Implementations/Observable.cs.meta → Observables/ObservableEventStream.cs.meta} +0 -0
- /package/Runtime/{Implementations → Observables}/ObservableList.cs.meta +0 -0
- /package/Runtime/{Implementations → Observables}/ObservableSet.cs.meta +0 -0
- /package/Runtime/{Implementations → Observables}/ObservableValue.cs.meta +0 -0
- /package/Runtime/{Observables/CastObservable.cs.meta → Operators/CastOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/CombineObservable.cs.meta → Operators/CombineOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/CombineValueObservable.cs.meta → Operators/CombineValueOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/ConcatObservable.cs.meta → Operators/ConcatOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/CountObservable.cs.meta → Operators/CountOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/DistinctObservable.cs.meta → Operators/DistinctOperator.cs.meta} +0 -0
- /package/Runtime/Operators/{CollectionOperator.cs.meta → Factories/CollectionOperatorFactory.cs.meta} +0 -0
- /package/Runtime/Operators/{DictionaryOperator.cs.meta → Factories/DictionaryOperatorFactory.cs.meta} +0 -0
- /package/Runtime/Operators/{ObservableOperator.cs.meta → Factories/EventStreamOperatorFactory.cs.meta} +0 -0
- /package/Runtime/Operators/{ListOperator.cs.meta → Factories/ListOperatorFactory.cs.meta} +0 -0
- /package/Runtime/Operators/{Operator.cs.meta → Factories/OperatorFactory.cs.meta} +0 -0
- /package/Runtime/Operators/{SetOperator.cs.meta → Factories/SetOperatorFactory.cs.meta} +0 -0
- /package/Runtime/Operators/{ValueOperator.cs.meta → Factories/ValueOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/FirstObservable.cs.meta → Operators/FirstOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/IndexOfObservable.cs.meta → Operators/IndexOfOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/OperationStreamObservable.cs.meta → Operators/OperationStreamOperator.cs.meta} +0 -0
- /package/Runtime/{Observables.cs.meta → Operators/Operators.cs.meta} +0 -0
- /package/Runtime/{Observables/OrderByObservable.cs.meta → Operators/OrderByOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/SelectCollectionObservable.cs.meta → Operators/SelectCollectionOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/SelectListObservable.cs.meta → Operators/SelectListOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/SelectManyObservable.cs.meta → Operators/SelectManyOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/SelectValueObservable.cs → Operators/SelectValueOperator.cs} +0 -0
- /package/Runtime/{Observables/SelectValueObservable.cs.meta → Operators/SelectValueOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/SkipWhileObservable.cs.meta → Operators/SkipWhileOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/ThenObservable.cs.meta → Operators/ThenOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/ToDictionaryObservable.cs.meta → Operators/ToDictionaryOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/TrackObservable.cs.meta → Operators/TrackOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/UnwrapCollectionObservable.cs.meta → Operators/UnwrapCollectionOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/UnwrapListObservable.cs.meta → Operators/UnwrapListOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/UnwrapValueObservable.cs.meta → Operators/UnwrapValueOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/WhereObservable.cs.meta → Operators/WhereOperator.cs.meta} +0 -0
- /package/Runtime/{Observables/WithPreviousObservable.cs.meta → Operators/WithPreviousOperator.cs.meta} +0 -0
|
@@ -2,9 +2,9 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace ObserveThing
|
|
4
4
|
{
|
|
5
|
-
public class
|
|
5
|
+
public class ValueOperatorFactory<T> : OperatorFactory<ObservableValue<T>>, IValueObservable<T>
|
|
6
6
|
{
|
|
7
|
-
public
|
|
7
|
+
public ValueOperatorFactory(ObservationContext context, Func<ObservableValue<T>, IDisposable> factory) : base(context, factory) { }
|
|
8
8
|
|
|
9
9
|
public IDisposable Subscribe(IValueObserver<T> observer, bool immediate = false, uint? priority = null)
|
|
10
10
|
{
|
|
@@ -19,12 +19,5 @@ namespace ObserveThing
|
|
|
19
19
|
var subscription = ((IValueObservable)_observable).Subscribe(observer, immediate, priority);
|
|
20
20
|
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
public IDisposable Subscribe(IObserver<IOperation> observer, bool immediate = false, uint? priority = null)
|
|
24
|
-
{
|
|
25
|
-
AddObserver(observer);
|
|
26
|
-
var subscription = ((IObservable<IOperation>)_observable).Subscribe(observer, immediate, priority);
|
|
27
|
-
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
28
|
-
}
|
|
29
22
|
}
|
|
30
23
|
}
|
|
@@ -3,14 +3,14 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class FirstOperator<T> : IDisposable
|
|
7
7
|
{
|
|
8
8
|
private ObservableValue<(bool found, T value)> _operand;
|
|
9
9
|
private List<(uint id, T value)> _sortedList = new List<(uint id, T value)>();
|
|
10
10
|
private (uint id, T value) _latest;
|
|
11
11
|
private IDisposable _subscriptions;
|
|
12
12
|
|
|
13
|
-
public
|
|
13
|
+
public FirstOperator(ICollectionObservable<T> source, Func<T, IValueObservable<bool>> validate, ObservableValue<(bool found, T value)> operand)
|
|
14
14
|
{
|
|
15
15
|
_operand = operand;
|
|
16
16
|
_subscriptions = source.ObservableWhere(x => validate(x)).SubscribeWithId(
|
|
@@ -3,14 +3,14 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class IndexOfOperator<T> : IDisposable
|
|
7
7
|
{
|
|
8
8
|
private ObservableValue<(bool found, int index)> _operand;
|
|
9
9
|
private T _latest = default;
|
|
10
10
|
private List<T> _list = new List<T>();
|
|
11
11
|
private IDisposable _subscriptions;
|
|
12
12
|
|
|
13
|
-
public
|
|
13
|
+
public IndexOfOperator(IListObservable<T> source, IValueObservable<T> value, ObservableValue<(bool found, int index)> operand)
|
|
14
14
|
{
|
|
15
15
|
_operand = operand;
|
|
16
16
|
_subscriptions = new ComposedDisposable(
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
|
|
4
|
+
namespace ObserveThing
|
|
5
|
+
{
|
|
6
|
+
public class ValueEventStreamOperator<T, TOperation> : IInitializationOperationsProvider<TOperation>, IDisposable
|
|
7
|
+
{
|
|
8
|
+
private IValueObservable<T> _source;
|
|
9
|
+
private Func<T, TOperation> _constructOperation;
|
|
10
|
+
private ObservableEventStream<TOperation> _operand;
|
|
11
|
+
private IDisposable _subscriptions;
|
|
12
|
+
|
|
13
|
+
public ValueEventStreamOperator(IValueObservable<T> source, Func<T, TOperation> constructOperation, ObservableEventStream<TOperation> operand)
|
|
14
|
+
{
|
|
15
|
+
_source = source;
|
|
16
|
+
_constructOperation = constructOperation;
|
|
17
|
+
_operand = operand;
|
|
18
|
+
|
|
19
|
+
_subscriptions = _source.Subscribe(
|
|
20
|
+
onNext: x => operand.EnqueueOperation(_constructOperation(x)),
|
|
21
|
+
onDispose: Dispose,
|
|
22
|
+
onError: operand.OnError,
|
|
23
|
+
immediate: true
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public IEnumerable<TOperation> GetInitializationOperations()
|
|
28
|
+
{
|
|
29
|
+
var initOperations = new List<TOperation>();
|
|
30
|
+
var subscription = _source.Subscribe(x => initOperations.Add(_constructOperation(x)));
|
|
31
|
+
subscription.Dispose();
|
|
32
|
+
|
|
33
|
+
foreach (var op in initOperations)
|
|
34
|
+
yield return op;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public void Dispose()
|
|
38
|
+
{
|
|
39
|
+
_subscriptions?.Dispose();
|
|
40
|
+
_subscriptions = null;
|
|
41
|
+
_operand.Dispose();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public class CollectionEventStreamOperator<T, TOperation> : IInitializationOperationsProvider<TOperation>, IDisposable
|
|
46
|
+
{
|
|
47
|
+
private ICollectionObservable<T> _source;
|
|
48
|
+
private Func<uint, T, TOperation> _constructAddOperation;
|
|
49
|
+
private Func<uint, T, TOperation> _constructRemoveOperation;
|
|
50
|
+
private ObservableEventStream<TOperation> _operand;
|
|
51
|
+
private IDisposable _subscriptions;
|
|
52
|
+
|
|
53
|
+
public CollectionEventStreamOperator(ICollectionObservable<T> source, Func<uint, T, TOperation> constructAddOperation, Func<uint, T, TOperation> constructRemoveOperation, ObservableEventStream<TOperation> operand)
|
|
54
|
+
{
|
|
55
|
+
_source = source;
|
|
56
|
+
_constructAddOperation = constructAddOperation;
|
|
57
|
+
_constructRemoveOperation = constructRemoveOperation;
|
|
58
|
+
_operand = operand;
|
|
59
|
+
|
|
60
|
+
_subscriptions = _source.SubscribeWithId(
|
|
61
|
+
onAdd: (id, element) => operand.EnqueueOperation(_constructAddOperation(id, element)),
|
|
62
|
+
onRemove: (id, element) => operand.EnqueueOperation(_constructRemoveOperation(id, element)),
|
|
63
|
+
onDispose: Dispose,
|
|
64
|
+
onError: operand.OnError,
|
|
65
|
+
immediate: true
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public IEnumerable<TOperation> GetInitializationOperations()
|
|
70
|
+
{
|
|
71
|
+
var initOperations = new List<TOperation>();
|
|
72
|
+
var subscription = _source.SubscribeWithId((id, element) => initOperations.Add(_constructAddOperation(id, element)));
|
|
73
|
+
subscription.Dispose();
|
|
74
|
+
|
|
75
|
+
foreach (var op in initOperations)
|
|
76
|
+
yield return op;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public void Dispose()
|
|
80
|
+
{
|
|
81
|
+
_subscriptions?.Dispose();
|
|
82
|
+
_subscriptions = null;
|
|
83
|
+
_operand.Dispose();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public class ListEventStreamOperator<T, TOperation> : IInitializationOperationsProvider<TOperation>, IDisposable
|
|
88
|
+
{
|
|
89
|
+
private IListObservable<T> _source;
|
|
90
|
+
private Func<uint, int, T, TOperation> _constructAddOperation;
|
|
91
|
+
private Func<uint, int, T, TOperation> _constructRemoveOperation;
|
|
92
|
+
private ObservableEventStream<TOperation> _operand;
|
|
93
|
+
private IDisposable _subscriptions;
|
|
94
|
+
|
|
95
|
+
public ListEventStreamOperator(IListObservable<T> source, Func<uint, int, T, TOperation> constructAddOperation, Func<uint, int, T, TOperation> constructRemoveOperation, ObservableEventStream<TOperation> operand)
|
|
96
|
+
{
|
|
97
|
+
_source = source;
|
|
98
|
+
_constructAddOperation = constructAddOperation;
|
|
99
|
+
_constructRemoveOperation = constructRemoveOperation;
|
|
100
|
+
_operand = operand;
|
|
101
|
+
|
|
102
|
+
_subscriptions = _source.SubscribeWithId(
|
|
103
|
+
onAdd: (id, index, element) => operand.EnqueueOperation(_constructAddOperation(id, index, element)),
|
|
104
|
+
onRemove: (id, index, element) => operand.EnqueueOperation(_constructRemoveOperation(id, index, element)),
|
|
105
|
+
onDispose: Dispose,
|
|
106
|
+
onError: operand.OnError,
|
|
107
|
+
immediate: true
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public IEnumerable<TOperation> GetInitializationOperations()
|
|
112
|
+
{
|
|
113
|
+
var initOperations = new List<TOperation>();
|
|
114
|
+
var subscription = _source.SubscribeWithId((id, index, element) => initOperations.Add(_constructAddOperation(id, index, element)));
|
|
115
|
+
subscription.Dispose();
|
|
116
|
+
|
|
117
|
+
foreach (var op in initOperations)
|
|
118
|
+
yield return op;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public void Dispose()
|
|
122
|
+
{
|
|
123
|
+
_subscriptions?.Dispose();
|
|
124
|
+
_subscriptions = null;
|
|
125
|
+
_operand.Dispose();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public class DictionaryEventStreamOperator<TKey, TValue, TOperation> : IInitializationOperationsProvider<TOperation>, IDisposable
|
|
130
|
+
{
|
|
131
|
+
private IDictionaryObservable<TKey, TValue> _source;
|
|
132
|
+
private Func<uint, KeyValuePair<TKey, TValue>, TOperation> _constructAddOperation;
|
|
133
|
+
private Func<uint, KeyValuePair<TKey, TValue>, TOperation> _constructRemoveOperation;
|
|
134
|
+
private ObservableEventStream<TOperation> _operand;
|
|
135
|
+
private IDisposable _subscriptions;
|
|
136
|
+
|
|
137
|
+
public DictionaryEventStreamOperator(IDictionaryObservable<TKey, TValue> source, Func<uint, KeyValuePair<TKey, TValue>, TOperation> constructAddOperation, Func<uint, KeyValuePair<TKey, TValue>, TOperation> constructRemoveOperation, ObservableEventStream<TOperation> operand)
|
|
138
|
+
{
|
|
139
|
+
_source = source;
|
|
140
|
+
_constructAddOperation = constructAddOperation;
|
|
141
|
+
_constructRemoveOperation = constructRemoveOperation;
|
|
142
|
+
_operand = operand;
|
|
143
|
+
|
|
144
|
+
_subscriptions = _source.SubscribeWithId(
|
|
145
|
+
onAdd: (id, kvp) => operand.EnqueueOperation(_constructAddOperation(id, kvp)),
|
|
146
|
+
onRemove: (id, kvp) => operand.EnqueueOperation(_constructRemoveOperation(id, kvp)),
|
|
147
|
+
onDispose: Dispose,
|
|
148
|
+
onError: operand.OnError,
|
|
149
|
+
immediate: true
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public IEnumerable<TOperation> GetInitializationOperations()
|
|
154
|
+
{
|
|
155
|
+
var initOperations = new List<TOperation>();
|
|
156
|
+
var subscription = _source.SubscribeWithId((id, kvp) => initOperations.Add(_constructAddOperation(id, kvp)));
|
|
157
|
+
subscription.Dispose();
|
|
158
|
+
|
|
159
|
+
foreach (var op in initOperations)
|
|
160
|
+
yield return op;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
public void Dispose()
|
|
164
|
+
{
|
|
165
|
+
_subscriptions?.Dispose();
|
|
166
|
+
_subscriptions = null;
|
|
167
|
+
_operand.Dispose();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
public class SetEventStreamOperator<T, TOperation> : IInitializationOperationsProvider<TOperation>, IDisposable
|
|
172
|
+
{
|
|
173
|
+
private ISetObservable<T> _source;
|
|
174
|
+
private Func<uint, T, TOperation> _constructAddOperation;
|
|
175
|
+
private Func<uint, T, TOperation> _constructRemoveOperation;
|
|
176
|
+
private ObservableEventStream<TOperation> _operand;
|
|
177
|
+
private IDisposable _subscriptions;
|
|
178
|
+
|
|
179
|
+
public SetEventStreamOperator(ISetObservable<T> source, Func<uint, T, TOperation> constructAddOperation, Func<uint, T, TOperation> constructRemoveOperation, ObservableEventStream<TOperation> operand)
|
|
180
|
+
{
|
|
181
|
+
_source = source;
|
|
182
|
+
_constructAddOperation = constructAddOperation;
|
|
183
|
+
_constructRemoveOperation = constructRemoveOperation;
|
|
184
|
+
_operand = operand;
|
|
185
|
+
|
|
186
|
+
_subscriptions = _source.SubscribeWithId(
|
|
187
|
+
onAdd: (id, element) => operand.EnqueueOperation(_constructAddOperation(id, element)),
|
|
188
|
+
onRemove: (id, element) => operand.EnqueueOperation(_constructRemoveOperation(id, element)),
|
|
189
|
+
onDispose: Dispose,
|
|
190
|
+
onError: operand.OnError,
|
|
191
|
+
immediate: true
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
public IEnumerable<TOperation> GetInitializationOperations()
|
|
196
|
+
{
|
|
197
|
+
var initOperations = new List<TOperation>();
|
|
198
|
+
var subscription = _source.SubscribeWithId((id, element) => initOperations.Add(_constructAddOperation(id, element)));
|
|
199
|
+
subscription.Dispose();
|
|
200
|
+
|
|
201
|
+
foreach (var op in initOperations)
|
|
202
|
+
yield return op;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public void Dispose()
|
|
206
|
+
{
|
|
207
|
+
_subscriptions?.Dispose();
|
|
208
|
+
_subscriptions = null;
|
|
209
|
+
_operand.Dispose();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|