com.fofx.observething 1.1.0-dev.36048653905 → 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
|
@@ -3,69 +3,70 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public
|
|
6
|
+
public class BatchOperator<T> : IInitializationOperationsProvider<IReadOnlyList<T>>, IPendingObserver
|
|
7
7
|
{
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
public bool immediate { get; } = false;
|
|
9
|
+
public uint priority { get; private set; }
|
|
10
|
+
public bool disposed { get; private set; }
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
private IEventStreamObservable<T> _source;
|
|
13
|
+
private ObservableEventStream<IReadOnlyList<T>> _operand;
|
|
14
|
+
private IDisposable _subscriptions;
|
|
15
|
+
private bool _pending;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
}
|
|
17
|
+
private List<T> _batchedOperations = new List<T>();
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// private IInitializationOperationsProvider<T> _operator;
|
|
23
|
-
// private bool _active = false;
|
|
19
|
+
public BatchOperator(IEventStreamObservable<T> source, ObservableEventStream<IReadOnlyList<T>> operand)
|
|
20
|
+
{
|
|
21
|
+
priority = source.context.AllocateObserverPriority();
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// _generateOperator = generateOperator;
|
|
28
|
-
// }
|
|
23
|
+
_source = source;
|
|
24
|
+
_operand = operand;
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
_subscriptions = source.Subscribe(new EventStreamObserver<T>(
|
|
27
|
+
onNext: HandleSourceOperation,
|
|
28
|
+
onError: operand.OnError,
|
|
29
|
+
onDispose: Dispose
|
|
30
|
+
), immediate: true);
|
|
31
|
+
}
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// _operator?.Dispose();
|
|
40
|
-
// _operator = null;
|
|
41
|
-
// }
|
|
33
|
+
private void HandleSourceOperation(T operation)
|
|
34
|
+
{
|
|
35
|
+
_batchedOperations.Add(operation);
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// _operator?.Dispose();
|
|
46
|
-
// _operator = null;
|
|
47
|
-
// }
|
|
37
|
+
if (_pending)
|
|
38
|
+
return;
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
_pending = true;
|
|
41
|
+
_source.context.RegisterPendingObserver(this);
|
|
42
|
+
_source.context.NotifyPendingObserversIfNecessary();
|
|
43
|
+
}
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
public IEnumerable<IReadOnlyList<T>> GetInitializationOperations()
|
|
46
|
+
{
|
|
47
|
+
List<T> initOps = new List<T>();
|
|
48
|
+
var subscription = _source.Subscribe(new EventStreamObserver<T>(x => initOps.Add(x)));
|
|
49
|
+
subscription.Dispose();
|
|
50
|
+
yield return initOps;
|
|
51
|
+
}
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// return;
|
|
53
|
+
public void SendNext()
|
|
54
|
+
{
|
|
55
|
+
_pending = false;
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
var batch = _batchedOperations.ToArray();
|
|
58
|
+
_batchedOperations.Clear();
|
|
62
59
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// yield return new BatchOp<T>() { source = this, operations = _operator.GetInitializationOperations() };
|
|
66
|
-
// }
|
|
60
|
+
_operand.EnqueueOperation(batch);
|
|
61
|
+
}
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
public void Dispose()
|
|
64
|
+
{
|
|
65
|
+
disposed = true;
|
|
66
|
+
_source.context.DeallocateObserverPriority(priority);
|
|
67
|
+
_subscriptions?.Dispose();
|
|
68
|
+
_subscriptions = null;
|
|
69
|
+
_operand.Dispose();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
71
72
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
fileFormatVersion: 2
|
|
2
|
-
guid:
|
|
2
|
+
guid: d36db333036392248810c9ce317875ec
|
|
@@ -2,12 +2,12 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace ObserveThing
|
|
4
4
|
{
|
|
5
|
-
public class
|
|
5
|
+
public class CastValueOperator<T> : IDisposable
|
|
6
6
|
{
|
|
7
7
|
private ObservableValue<T> _operand;
|
|
8
8
|
private IDisposable _subscription;
|
|
9
9
|
|
|
10
|
-
public
|
|
10
|
+
public CastValueOperator(IValueObservable source, ObservableValue<T> operand)
|
|
11
11
|
{
|
|
12
12
|
_operand = operand;
|
|
13
13
|
_subscription = source.Subscribe(
|
|
@@ -26,12 +26,12 @@ namespace ObserveThing
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
public class
|
|
29
|
+
public class CastCollectionOperator<T> : IDisposable
|
|
30
30
|
{
|
|
31
31
|
private ObservableCollection<T> _operand;
|
|
32
32
|
private IDisposable _subscription;
|
|
33
33
|
|
|
34
|
-
public
|
|
34
|
+
public CastCollectionOperator(ICollectionObservable source, ObservableCollection<T> operand)
|
|
35
35
|
{
|
|
36
36
|
_operand = operand;
|
|
37
37
|
_subscription = source.SubscribeWithId(
|
|
@@ -51,12 +51,12 @@ namespace ObserveThing
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
public class
|
|
54
|
+
public class CastListOperator<T> : IDisposable
|
|
55
55
|
{
|
|
56
56
|
private ObservableList<T> _operand;
|
|
57
57
|
private IDisposable _subscription;
|
|
58
58
|
|
|
59
|
-
public
|
|
59
|
+
public CastListOperator(IListObservable source, ObservableList<T> operand)
|
|
60
60
|
{
|
|
61
61
|
_operand = operand;
|
|
62
62
|
_subscription = source.Subscribe(
|
|
@@ -76,12 +76,12 @@ namespace ObserveThing
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
public class
|
|
79
|
+
public class CastSetOperator<T> : IDisposable
|
|
80
80
|
{
|
|
81
81
|
private ObservableSet<T> _operand;
|
|
82
82
|
private IDisposable _subscription;
|
|
83
83
|
|
|
84
|
-
public
|
|
84
|
+
public CastSetOperator(ISetObservable source, ObservableSet<T> operand)
|
|
85
85
|
{
|
|
86
86
|
_operand = operand;
|
|
87
87
|
_subscription = source.Subscribe(
|
|
@@ -101,12 +101,12 @@ namespace ObserveThing
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
public class
|
|
104
|
+
public class CastDictionaryOperator<TKey, TValue> : IDisposable
|
|
105
105
|
{
|
|
106
106
|
private ObservableDictionary<TKey, TValue> _operand;
|
|
107
107
|
private IDisposable _subscription;
|
|
108
108
|
|
|
109
|
-
public
|
|
109
|
+
public CastDictionaryOperator(IDictionaryObservable source, ObservableDictionary<TKey, TValue> operand)
|
|
110
110
|
{
|
|
111
111
|
_operand = operand;
|
|
112
112
|
_subscription = source.Subscribe(
|
|
@@ -3,23 +3,23 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class CombineOperator<T> : IInitializationOperationsProvider<T>
|
|
7
7
|
{
|
|
8
|
-
private ISetObservable<
|
|
9
|
-
private
|
|
8
|
+
private ISetObservable<IEventStreamObservable<T>> _source;
|
|
9
|
+
private ObservableEventStream<T> _operand;
|
|
10
10
|
private bool _disposeOnSourceEmpty;
|
|
11
11
|
private uint _elementPriority;
|
|
12
|
-
private Dictionary<
|
|
12
|
+
private Dictionary<IEventStreamObservable<T>, IDisposable> _observables = new Dictionary<IEventStreamObservable<T>, IDisposable>();
|
|
13
13
|
private IDisposable _subscriptions;
|
|
14
14
|
private bool _disposed;
|
|
15
15
|
|
|
16
|
-
public
|
|
16
|
+
public CombineOperator(ISetObservable<IEventStreamObservable<T>> source, ObservableEventStream<T> operand, bool disposeOnSourceEmpty = false)
|
|
17
17
|
{
|
|
18
18
|
_source = source;
|
|
19
19
|
_operand = operand;
|
|
20
20
|
_disposeOnSourceEmpty = disposeOnSourceEmpty;
|
|
21
21
|
_elementPriority = _source.context.AllocateObserverPriority();
|
|
22
|
-
_subscriptions = _source.Subscribe(new SetObserver<
|
|
22
|
+
_subscriptions = _source.Subscribe(new SetObserver<IEventStreamObservable<T>>(
|
|
23
23
|
onAdd: HandleElementAdded,
|
|
24
24
|
onRemove: HandleElementRemoved,
|
|
25
25
|
onError: _operand.OnError,
|
|
@@ -33,7 +33,7 @@ namespace ObserveThing
|
|
|
33
33
|
|
|
34
34
|
foreach (var element in _observables.Keys)
|
|
35
35
|
{
|
|
36
|
-
var subscription = element.Subscribe(new
|
|
36
|
+
var subscription = element.Subscribe(new EventStreamObserver<T>(x => initOps.Add(x)));
|
|
37
37
|
subscription.Dispose();
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -41,11 +41,11 @@ namespace ObserveThing
|
|
|
41
41
|
yield return op;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
private void HandleElementAdded(uint _,
|
|
44
|
+
private void HandleElementAdded(uint _, IEventStreamObservable<T> observable)
|
|
45
45
|
{
|
|
46
46
|
_observables.Add(
|
|
47
47
|
observable,
|
|
48
|
-
observable.Subscribe(new
|
|
48
|
+
observable.Subscribe(new EventStreamObserver<T>(
|
|
49
49
|
onNext: HandleElementChanged,
|
|
50
50
|
onError: _operand.OnError,
|
|
51
51
|
onDispose: () =>
|
|
@@ -59,7 +59,7 @@ namespace ObserveThing
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
private void HandleElementRemoved(uint _,
|
|
62
|
+
private void HandleElementRemoved(uint _, IEventStreamObservable<T> observable)
|
|
63
63
|
{
|
|
64
64
|
if (!_observables.TryGetValue(observable, out var subscription))
|
|
65
65
|
return;
|
|
@@ -2,12 +2,12 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace ObserveThing
|
|
4
4
|
{
|
|
5
|
-
public class
|
|
5
|
+
public class CombineValueOperator<T1, T2> : IDisposable
|
|
6
6
|
{
|
|
7
7
|
private ObservableValue<(T1, T2)> _operand;
|
|
8
8
|
private IDisposable _subscriptions;
|
|
9
9
|
|
|
10
|
-
public
|
|
10
|
+
public CombineValueOperator(IValueObservable<T1> source1, IValueObservable<T2> source2, ObservableValue<(T1, T2)> operand)
|
|
11
11
|
{
|
|
12
12
|
_operand = operand;
|
|
13
13
|
_subscriptions = new ComposedDisposable(
|
|
@@ -37,12 +37,12 @@ namespace ObserveThing
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
public class
|
|
40
|
+
public class CombineValueOperator<T1, T2, T3> : IDisposable
|
|
41
41
|
{
|
|
42
42
|
private ObservableValue<(T1, T2, T3)> _operand;
|
|
43
43
|
private IDisposable _subscriptions;
|
|
44
44
|
|
|
45
|
-
public
|
|
45
|
+
public CombineValueOperator(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, ObservableValue<(T1, T2, T3)> operand)
|
|
46
46
|
{
|
|
47
47
|
_operand = operand;
|
|
48
48
|
_subscriptions = new ComposedDisposable(
|
|
@@ -79,12 +79,12 @@ namespace ObserveThing
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
public class
|
|
82
|
+
public class CombineValueOperator<T1, T2, T3, T4> : IDisposable
|
|
83
83
|
{
|
|
84
84
|
private ObservableValue<(T1, T2, T3, T4)> _operand;
|
|
85
85
|
private IDisposable _subscriptions;
|
|
86
86
|
|
|
87
|
-
public
|
|
87
|
+
public CombineValueOperator(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, IValueObservable<T4> source4, ObservableValue<(T1, T2, T3, T4)> operand)
|
|
88
88
|
{
|
|
89
89
|
_operand = operand;
|
|
90
90
|
_subscriptions = new ComposedDisposable(
|
|
@@ -128,12 +128,12 @@ namespace ObserveThing
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
public class
|
|
131
|
+
public class CombineValueOperator<T1, T2, T3, T4, T5> : IDisposable
|
|
132
132
|
{
|
|
133
133
|
private ObservableValue<(T1, T2, T3, T4, T5)> _operand;
|
|
134
134
|
private IDisposable _subscriptions;
|
|
135
135
|
|
|
136
|
-
public
|
|
136
|
+
public CombineValueOperator(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, IValueObservable<T4> source4, IValueObservable<T5> source5, ObservableValue<(T1, T2, T3, T4, T5)> operand)
|
|
137
137
|
{
|
|
138
138
|
_operand = operand;
|
|
139
139
|
_subscriptions = new ComposedDisposable(
|
|
@@ -184,12 +184,12 @@ namespace ObserveThing
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
public class
|
|
187
|
+
public class CombineValueOperator<T1, T2, T3, T4, T5, T6> : IDisposable
|
|
188
188
|
{
|
|
189
189
|
private ObservableValue<(T1, T2, T3, T4, T5, T6)> _operand;
|
|
190
190
|
private IDisposable _subscriptions;
|
|
191
191
|
|
|
192
|
-
public
|
|
192
|
+
public CombineValueOperator(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, IValueObservable<T4> source4, IValueObservable<T5> source5, IValueObservable<T6> source6, ObservableValue<(T1, T2, T3, T4, T5, T6)> operand)
|
|
193
193
|
{
|
|
194
194
|
_operand = operand;
|
|
195
195
|
_subscriptions = new ComposedDisposable(
|
|
@@ -247,12 +247,12 @@ namespace ObserveThing
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
-
public class
|
|
250
|
+
public class CombineValueOperator<T1, T2, T3, T4, T5, T6, T7> : IDisposable
|
|
251
251
|
{
|
|
252
252
|
private ObservableValue<(T1, T2, T3, T4, T5, T6, T7)> _operand;
|
|
253
253
|
private IDisposable _subscriptions;
|
|
254
254
|
|
|
255
|
-
public
|
|
255
|
+
public CombineValueOperator(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, IValueObservable<T4> source4, IValueObservable<T5> source5, IValueObservable<T6> source6, IValueObservable<T7> source7, ObservableValue<(T1, T2, T3, T4, T5, T6, T7)> operand)
|
|
256
256
|
{
|
|
257
257
|
_operand = operand;
|
|
258
258
|
_subscriptions = new ComposedDisposable(
|
|
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class ConcatOperator<T> : IDisposable
|
|
7
7
|
{
|
|
8
8
|
private ObservableCollection<T> _operand;
|
|
9
9
|
private CollectionIdProvider _idProvider;
|
|
@@ -12,7 +12,7 @@ namespace ObserveThing
|
|
|
12
12
|
|
|
13
13
|
private IDisposable _subscription;
|
|
14
14
|
|
|
15
|
-
public
|
|
15
|
+
public ConcatOperator(ICollectionObservable<T> source1, ICollectionObservable<T> source2, ObservableCollection<T> operand)
|
|
16
16
|
{
|
|
17
17
|
_idProvider = new CollectionIdProvider(x => !_source1IdMap.ContainsValue(x) && !_source2IdMap.ContainsValue(x));
|
|
18
18
|
_operand = operand;
|
|
@@ -3,14 +3,14 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class ContainsOperator<T> : IDisposable
|
|
7
7
|
{
|
|
8
8
|
private ObservableValue<bool> _operand;
|
|
9
9
|
private List<T> _list = new List<T>();
|
|
10
10
|
private T _latest = default;
|
|
11
11
|
private IDisposable _subscriptions;
|
|
12
12
|
|
|
13
|
-
public
|
|
13
|
+
public ContainsOperator(ICollectionObservable<T> source, IValueObservable<T> value, ObservableValue<bool> operand)
|
|
14
14
|
{
|
|
15
15
|
_operand = operand;
|
|
16
16
|
_subscriptions = new ComposedDisposable(
|
|
@@ -2,12 +2,12 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace ObserveThing
|
|
4
4
|
{
|
|
5
|
-
public class
|
|
5
|
+
public class CountOperator<T> : IDisposable
|
|
6
6
|
{
|
|
7
7
|
private ObservableValue<int> _operand;
|
|
8
8
|
private IDisposable _subscriptions;
|
|
9
9
|
|
|
10
|
-
public
|
|
10
|
+
public CountOperator(ICollectionObservable<T> source, ObservableValue<int> operand)
|
|
11
11
|
{
|
|
12
12
|
_operand = operand;
|
|
13
13
|
_subscriptions = source.Subscribe(
|
|
@@ -3,13 +3,13 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class DistinctOperator<T> : IDisposable
|
|
7
7
|
{
|
|
8
8
|
private ObservableSet<T> _operand;
|
|
9
9
|
private Dictionary<T, int> _countByElement = new Dictionary<T, int>();
|
|
10
10
|
private IDisposable _subscriptions;
|
|
11
11
|
|
|
12
|
-
public
|
|
12
|
+
public DistinctOperator(ICollectionObservable<T> source, ObservableSet<T> operand)
|
|
13
13
|
{
|
|
14
14
|
_operand = operand;
|
|
15
15
|
_subscriptions = source.Subscribe(
|
|
@@ -2,9 +2,9 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace ObserveThing
|
|
4
4
|
{
|
|
5
|
-
public class
|
|
5
|
+
public class CollectionOperatorFactory<T> : OperatorFactory<ObservableCollection<T>>, ICollectionObservable<T>
|
|
6
6
|
{
|
|
7
|
-
public
|
|
7
|
+
public CollectionOperatorFactory(ObservationContext context, Func<ObservableCollection<T>, IDisposable> factory) : base(context, factory) { }
|
|
8
8
|
|
|
9
9
|
public IDisposable Subscribe(ICollectionObserver<T> observer, bool immediate = false, uint? priority = null)
|
|
10
10
|
{
|
|
@@ -19,12 +19,5 @@ namespace ObserveThing
|
|
|
19
19
|
var subscription = ((ICollectionObservable)_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,9 +3,9 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class DictionaryOperatorFactory<TKey, TValue> : OperatorFactory<ObservableDictionary<TKey, TValue>>, IDictionaryObservable<TKey, TValue>
|
|
7
7
|
{
|
|
8
|
-
public
|
|
8
|
+
public DictionaryOperatorFactory(ObservationContext context, Func<ObservableDictionary<TKey, TValue>, IDisposable> factory) : base(context, factory) { }
|
|
9
9
|
|
|
10
10
|
public IDisposable Subscribe(IDictionaryObserver<TKey, TValue> observer, bool immediate = false, uint? priority = null)
|
|
11
11
|
{
|
|
@@ -34,12 +34,5 @@ namespace ObserveThing
|
|
|
34
34
|
var subscription = ((ICollectionObservable)_observable).Subscribe(observer, immediate, priority);
|
|
35
35
|
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
public IDisposable Subscribe(IObserver<IOperation> observer, bool immediate = false, uint? priority = null)
|
|
39
|
-
{
|
|
40
|
-
AddObserver(observer);
|
|
41
|
-
var subscription = ((IObservable<IOperation>)_observable).Subscribe(observer, immediate, priority);
|
|
42
|
-
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
43
|
-
}
|
|
44
37
|
}
|
|
45
38
|
}
|
|
@@ -3,21 +3,21 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class EventStreamOperatorFactory<T> : IEventStreamObservable<T>, IInitializationOperationsProvider<T>
|
|
7
7
|
{
|
|
8
8
|
public ObservationContext context { get; }
|
|
9
9
|
|
|
10
|
-
private Func<
|
|
11
|
-
protected
|
|
10
|
+
private Func<ObservableEventStream<T>, IInitializationOperationsProvider<T>> _generateOperator;
|
|
11
|
+
protected ObservableEventStream<T> _observable { get; private set; }
|
|
12
12
|
private IInitializationOperationsProvider<T> _operator;
|
|
13
13
|
private bool _active = false;
|
|
14
|
-
private List<
|
|
14
|
+
private List<IObserver> _observers = new List<IObserver>();
|
|
15
15
|
private bool _disposed;
|
|
16
16
|
|
|
17
|
-
public
|
|
17
|
+
public EventStreamOperatorFactory(ObservationContext context, Func<ObservableEventStream<T>, IInitializationOperationsProvider<T>> factory)
|
|
18
18
|
{
|
|
19
19
|
this.context = context;
|
|
20
|
-
_generateOperator =
|
|
20
|
+
_generateOperator = factory;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
public void Dispose()
|
|
@@ -34,7 +34,7 @@ namespace ObserveThing
|
|
|
34
34
|
_observable = default;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
protected void AddObserver(
|
|
37
|
+
protected void AddObserver(IObserver observer)
|
|
38
38
|
{
|
|
39
39
|
_observers.Add(observer);
|
|
40
40
|
|
|
@@ -42,11 +42,11 @@ namespace ObserveThing
|
|
|
42
42
|
return;
|
|
43
43
|
|
|
44
44
|
_active = true;
|
|
45
|
-
_observable = new
|
|
45
|
+
_observable = new ObservableEventStream<T>(context, this);
|
|
46
46
|
_operator = _generateOperator(_observable);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
protected void RemoveObserver(
|
|
49
|
+
protected void RemoveObserver(IObserver observer)
|
|
50
50
|
{
|
|
51
51
|
_observers.Remove(observer);
|
|
52
52
|
|
|
@@ -62,13 +62,20 @@ namespace ObserveThing
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
public IDisposable Subscribe(
|
|
65
|
+
public IDisposable Subscribe(IEventStreamObserver<T> observer, bool immediate = false, uint? priority = null)
|
|
66
66
|
{
|
|
67
67
|
AddObserver(observer);
|
|
68
68
|
var subscription = _observable.Subscribe(observer, immediate, priority);
|
|
69
69
|
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
public IDisposable Subscribe(IEventStreamObserver observer, bool immediate = false, uint? priority = null)
|
|
73
|
+
{
|
|
74
|
+
AddObserver(observer);
|
|
75
|
+
var subscription = ((IEventStreamObservable)_observable).Subscribe(observer, immediate, priority);
|
|
76
|
+
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
public IEnumerable<T> GetInitializationOperations()
|
|
73
80
|
=> _operator.GetInitializationOperations();
|
|
74
81
|
}
|
|
@@ -2,9 +2,9 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace ObserveThing
|
|
4
4
|
{
|
|
5
|
-
public class
|
|
5
|
+
public class ListOperatorFactory<T> : OperatorFactory<ObservableList<T>>, IListObservable<T>
|
|
6
6
|
{
|
|
7
|
-
public
|
|
7
|
+
public ListOperatorFactory(ObservationContext context, Func<ObservableList<T>, IDisposable> factory) : base(context, factory) { }
|
|
8
8
|
|
|
9
9
|
public IDisposable Subscribe(IListObserver<T> observer, bool immediate = false, uint? priority = null)
|
|
10
10
|
{
|
|
@@ -33,12 +33,5 @@ namespace ObserveThing
|
|
|
33
33
|
var subscription = ((ICollectionObservable)_observable).Subscribe(observer, immediate, priority);
|
|
34
34
|
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
public IDisposable Subscribe(IObserver<IOperation> observer, bool immediate = false, uint? priority = null)
|
|
38
|
-
{
|
|
39
|
-
AddObserver(observer);
|
|
40
|
-
var subscription = ((IObservable<IOperation>)_observable).Subscribe(observer, immediate, priority);
|
|
41
|
-
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
42
|
-
}
|
|
43
36
|
}
|
|
44
37
|
}
|
|
@@ -3,21 +3,21 @@ using System.Collections.Generic;
|
|
|
3
3
|
|
|
4
4
|
namespace ObserveThing
|
|
5
5
|
{
|
|
6
|
-
public class
|
|
6
|
+
public class OperatorFactory<T> where T : class, IDisposable, new()
|
|
7
7
|
{
|
|
8
8
|
public ObservationContext context { get; }
|
|
9
9
|
|
|
10
|
-
private Func<T, IDisposable>
|
|
10
|
+
private Func<T, IDisposable> _factory;
|
|
11
11
|
protected T _observable { get; private set; }
|
|
12
12
|
private IDisposable _operator;
|
|
13
13
|
private bool _active = false;
|
|
14
|
-
private List<
|
|
14
|
+
private List<IObserver> _observers = new List<IObserver>();
|
|
15
15
|
private bool _disposed;
|
|
16
16
|
|
|
17
|
-
public
|
|
17
|
+
public OperatorFactory(ObservationContext context, Func<T, IDisposable> factory)
|
|
18
18
|
{
|
|
19
19
|
this.context = context;
|
|
20
|
-
|
|
20
|
+
_factory = factory;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
public void Dispose()
|
|
@@ -34,7 +34,7 @@ namespace ObserveThing
|
|
|
34
34
|
_observable = default;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
protected void AddObserver(
|
|
37
|
+
protected void AddObserver(IObserver observer)
|
|
38
38
|
{
|
|
39
39
|
_observers.Add(observer);
|
|
40
40
|
|
|
@@ -43,10 +43,10 @@ namespace ObserveThing
|
|
|
43
43
|
|
|
44
44
|
_active = true;
|
|
45
45
|
_observable = new T();
|
|
46
|
-
_operator =
|
|
46
|
+
_operator = _factory(_observable);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
protected void RemoveObserver(
|
|
49
|
+
protected void RemoveObserver(IObserver observer)
|
|
50
50
|
{
|
|
51
51
|
_observers.Remove(observer);
|
|
52
52
|
|
|
@@ -2,9 +2,9 @@ using System;
|
|
|
2
2
|
|
|
3
3
|
namespace ObserveThing
|
|
4
4
|
{
|
|
5
|
-
public class
|
|
5
|
+
public class SetOperatorFactory<T> : OperatorFactory<ObservableSet<T>>, ISetObservable<T>
|
|
6
6
|
{
|
|
7
|
-
public
|
|
7
|
+
public SetOperatorFactory(ObservationContext context, Func<ObservableSet<T>, IDisposable> factory) : base(context, factory) { }
|
|
8
8
|
|
|
9
9
|
public IDisposable Subscribe(ISetObserver<T> observer, bool immediate = false, uint? priority = null)
|
|
10
10
|
{
|
|
@@ -33,12 +33,5 @@ namespace ObserveThing
|
|
|
33
33
|
var subscription = ((ICollectionObservable)_observable).Subscribe(observer, immediate, priority);
|
|
34
34
|
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
public IDisposable Subscribe(IObserver<IOperation> observer, bool immediate = false, uint? priority = null)
|
|
38
|
-
{
|
|
39
|
-
AddObserver(observer);
|
|
40
|
-
var subscription = ((IObservable<IOperation>)_observable).Subscribe(observer, immediate, priority);
|
|
41
|
-
return new ComposedDisposable(subscription, new Disposable(() => RemoveObserver(observer)));
|
|
42
|
-
}
|
|
43
36
|
}
|
|
44
37
|
}
|