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.
Files changed (99) hide show
  1. package/Runtime/{Operators/IInitializationOperationsProvider.cs → IInitializationOperationsProvider.cs} +1 -1
  2. package/Runtime/{IObservable.cs → Observables/IObservable.cs} +13 -9
  3. package/Runtime/{Implementations/ObservableBase.cs → Observables/Observable.cs} +6 -19
  4. package/Runtime/{Implementations → Observables}/ObservableCollection.cs +6 -15
  5. package/Runtime/{Implementations → Observables}/ObservableDictionary.cs +7 -18
  6. package/Runtime/{Implementations/Observable.cs → Observables/ObservableEventStream.cs} +11 -3
  7. package/Runtime/{Implementations → Observables}/ObservableList.cs +3 -13
  8. package/Runtime/{Implementations → Observables}/ObservableSet.cs +6 -15
  9. package/Runtime/{Implementations → Observables}/ObservableValue.cs +4 -11
  10. package/Runtime/Observables.meta +1 -1
  11. package/Runtime/ObservationDefaults.cs +10 -0
  12. package/Runtime/ObservationDefaults.cs.meta +2 -0
  13. package/Runtime/Observers.cs +51 -64
  14. package/Runtime/Operators/BatchOperator.cs +52 -51
  15. package/Runtime/Operators/BatchOperator.cs.meta +1 -1
  16. package/Runtime/{Observables/CastObservable.cs → Operators/CastOperator.cs} +10 -10
  17. package/Runtime/{Observables/CombineObservable.cs → Operators/CombineOperator.cs} +10 -10
  18. package/Runtime/{Observables/CombineValueObservable.cs → Operators/CombineValueOperator.cs} +12 -12
  19. package/Runtime/{Observables/ConcatObservable.cs → Operators/ConcatOperator.cs} +2 -2
  20. package/Runtime/{Observables/ContainsObservable.cs → Operators/ContainsOperator.cs} +2 -2
  21. package/Runtime/Operators/ContainsOperator.cs.meta +2 -0
  22. package/Runtime/{Observables/CountObservable.cs → Operators/CountOperator.cs} +2 -2
  23. package/Runtime/{Observables/DistinctObservable.cs → Operators/DistinctOperator.cs} +2 -2
  24. package/Runtime/Operators/{CollectionOperator.cs → Factories/CollectionOperatorFactory.cs} +2 -9
  25. package/Runtime/Operators/{DictionaryOperator.cs → Factories/DictionaryOperatorFactory.cs} +2 -9
  26. package/Runtime/Operators/{ObservableOperator.cs → Factories/EventStreamOperatorFactory.cs} +17 -10
  27. package/Runtime/Operators/{ListOperator.cs → Factories/ListOperatorFactory.cs} +2 -9
  28. package/Runtime/Operators/{Operator.cs → Factories/OperatorFactory.cs} +8 -8
  29. package/Runtime/Operators/{SetOperator.cs → Factories/SetOperatorFactory.cs} +2 -9
  30. package/Runtime/Operators/{ValueOperator.cs → Factories/ValueOperator.cs} +2 -9
  31. package/Runtime/{Implementations.meta → Operators/Factories.meta} +1 -1
  32. package/Runtime/{Observables/FirstObservable.cs → Operators/FirstOperator.cs} +2 -2
  33. package/Runtime/{Observables/IndexOfObservable.cs → Operators/IndexOfOperator.cs} +2 -2
  34. package/Runtime/Operators/OperationStreamOperator.cs +212 -0
  35. package/Runtime/{Observables.cs → Operators/Operators.cs} +105 -73
  36. package/Runtime/{Observables/OrderByObservable.cs → Operators/OrderByOperator.cs} +2 -2
  37. package/Runtime/{Observables/SelectCollectionObservable.cs → Operators/SelectCollectionOperator.cs} +2 -2
  38. package/Runtime/{Observables/SelectListObservable.cs → Operators/SelectListOperator.cs} +2 -2
  39. package/Runtime/{Observables/SelectManyObservable.cs → Operators/SelectManyOperator.cs} +2 -2
  40. package/Runtime/{Observables/SkipWhileObservable.cs → Operators/SkipWhileOperator.cs} +2 -2
  41. package/Runtime/{Observables/ThenObservable.cs → Operators/ThenOperator.cs} +2 -2
  42. package/Runtime/{Observables/ToDictionaryObservable.cs → Operators/ToDictionaryOperator.cs} +3 -3
  43. package/Runtime/{Observables/TrackObservable.cs → Operators/TrackOperator.cs} +2 -2
  44. package/Runtime/{Observables/UnwrapCollectionObservable.cs → Operators/UnwrapCollectionOperator.cs} +2 -2
  45. package/Runtime/{Observables/UnwrapListObservable.cs → Operators/UnwrapListOperator.cs} +2 -2
  46. package/Runtime/{Observables/UnwrapValueObservable.cs → Operators/UnwrapValueOperator.cs} +2 -2
  47. package/Runtime/{Observables/WhereObservable.cs → Operators/WhereOperator.cs} +2 -2
  48. package/Runtime/{Observables/WithPreviousObservable.cs → Operators/WithPreviousOperator.cs} +2 -2
  49. package/Tests/CollectionObservableTests.cs +1 -1
  50. package/Tests/DictionaryObservableTests.cs +1 -1
  51. package/Tests/ListObservableTests.cs +1 -1
  52. package/Tests/ObservationContextTests.cs +109 -83
  53. package/Tests/ValueObservableTests.cs +1 -1
  54. package/package.json +5 -4
  55. package/Runtime/Observables/BatchObservable.cs +0 -72
  56. package/Runtime/Observables/BatchObservable.cs.meta +0 -2
  57. package/Runtime/Observables/ContainsObservable.cs.meta +0 -2
  58. package/Runtime/Observables/OperationStreamObservable.cs +0 -194
  59. /package/Runtime/{Operators/IInitializationOperationsProvider.cs.meta → IInitializationOperationsProvider.cs.meta} +0 -0
  60. /package/Runtime/{IObservable.cs.meta → Observables/IObservable.cs.meta} +0 -0
  61. /package/Runtime/{Implementations/ObservableBase.cs.meta → Observables/Observable.cs.meta} +0 -0
  62. /package/Runtime/{Implementations → Observables}/ObservableCollection.cs.meta +0 -0
  63. /package/Runtime/{Implementations → Observables}/ObservableDictionary.cs.meta +0 -0
  64. /package/Runtime/{Implementations/Observable.cs.meta → Observables/ObservableEventStream.cs.meta} +0 -0
  65. /package/Runtime/{Implementations → Observables}/ObservableList.cs.meta +0 -0
  66. /package/Runtime/{Implementations → Observables}/ObservableSet.cs.meta +0 -0
  67. /package/Runtime/{Implementations → Observables}/ObservableValue.cs.meta +0 -0
  68. /package/Runtime/{Observables/CastObservable.cs.meta → Operators/CastOperator.cs.meta} +0 -0
  69. /package/Runtime/{Observables/CombineObservable.cs.meta → Operators/CombineOperator.cs.meta} +0 -0
  70. /package/Runtime/{Observables/CombineValueObservable.cs.meta → Operators/CombineValueOperator.cs.meta} +0 -0
  71. /package/Runtime/{Observables/ConcatObservable.cs.meta → Operators/ConcatOperator.cs.meta} +0 -0
  72. /package/Runtime/{Observables/CountObservable.cs.meta → Operators/CountOperator.cs.meta} +0 -0
  73. /package/Runtime/{Observables/DistinctObservable.cs.meta → Operators/DistinctOperator.cs.meta} +0 -0
  74. /package/Runtime/Operators/{CollectionOperator.cs.meta → Factories/CollectionOperatorFactory.cs.meta} +0 -0
  75. /package/Runtime/Operators/{DictionaryOperator.cs.meta → Factories/DictionaryOperatorFactory.cs.meta} +0 -0
  76. /package/Runtime/Operators/{ObservableOperator.cs.meta → Factories/EventStreamOperatorFactory.cs.meta} +0 -0
  77. /package/Runtime/Operators/{ListOperator.cs.meta → Factories/ListOperatorFactory.cs.meta} +0 -0
  78. /package/Runtime/Operators/{Operator.cs.meta → Factories/OperatorFactory.cs.meta} +0 -0
  79. /package/Runtime/Operators/{SetOperator.cs.meta → Factories/SetOperatorFactory.cs.meta} +0 -0
  80. /package/Runtime/Operators/{ValueOperator.cs.meta → Factories/ValueOperator.cs.meta} +0 -0
  81. /package/Runtime/{Observables/FirstObservable.cs.meta → Operators/FirstOperator.cs.meta} +0 -0
  82. /package/Runtime/{Observables/IndexOfObservable.cs.meta → Operators/IndexOfOperator.cs.meta} +0 -0
  83. /package/Runtime/{Observables/OperationStreamObservable.cs.meta → Operators/OperationStreamOperator.cs.meta} +0 -0
  84. /package/Runtime/{Observables.cs.meta → Operators/Operators.cs.meta} +0 -0
  85. /package/Runtime/{Observables/OrderByObservable.cs.meta → Operators/OrderByOperator.cs.meta} +0 -0
  86. /package/Runtime/{Observables/SelectCollectionObservable.cs.meta → Operators/SelectCollectionOperator.cs.meta} +0 -0
  87. /package/Runtime/{Observables/SelectListObservable.cs.meta → Operators/SelectListOperator.cs.meta} +0 -0
  88. /package/Runtime/{Observables/SelectManyObservable.cs.meta → Operators/SelectManyOperator.cs.meta} +0 -0
  89. /package/Runtime/{Observables/SelectValueObservable.cs → Operators/SelectValueOperator.cs} +0 -0
  90. /package/Runtime/{Observables/SelectValueObservable.cs.meta → Operators/SelectValueOperator.cs.meta} +0 -0
  91. /package/Runtime/{Observables/SkipWhileObservable.cs.meta → Operators/SkipWhileOperator.cs.meta} +0 -0
  92. /package/Runtime/{Observables/ThenObservable.cs.meta → Operators/ThenOperator.cs.meta} +0 -0
  93. /package/Runtime/{Observables/ToDictionaryObservable.cs.meta → Operators/ToDictionaryOperator.cs.meta} +0 -0
  94. /package/Runtime/{Observables/TrackObservable.cs.meta → Operators/TrackOperator.cs.meta} +0 -0
  95. /package/Runtime/{Observables/UnwrapCollectionObservable.cs.meta → Operators/UnwrapCollectionOperator.cs.meta} +0 -0
  96. /package/Runtime/{Observables/UnwrapListObservable.cs.meta → Operators/UnwrapListOperator.cs.meta} +0 -0
  97. /package/Runtime/{Observables/UnwrapValueObservable.cs.meta → Operators/UnwrapValueOperator.cs.meta} +0 -0
  98. /package/Runtime/{Observables/WhereObservable.cs.meta → Operators/WhereOperator.cs.meta} +0 -0
  99. /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 interface IBatchOp<T> : IOperation where T : IOperation
6
+ public class BatchOperator<T> : IInitializationOperationsProvider<IReadOnlyList<T>>, IPendingObserver
7
7
  {
8
- IReadOnlyList<T> operations { get; set; }
9
- }
8
+ public bool immediate { get; } = false;
9
+ public uint priority { get; private set; }
10
+ public bool disposed { get; private set; }
10
11
 
11
- public struct BatchOp<T> : IBatchOp<T> where T : IOperation
12
- {
13
- public IObservable<T> source { get; set; }
14
- public IReadOnlyList<T> operations { get; set; }
12
+ private IEventStreamObservable<T> _source;
13
+ private ObservableEventStream<IReadOnlyList<T>> _operand;
14
+ private IDisposable _subscriptions;
15
+ private bool _pending;
15
16
 
16
- IObservable<IOperation> IOperation.source => (IObservable<IOperation>)source;
17
- }
17
+ private List<T> _batchedOperations = new List<T>();
18
18
 
19
- // public class BatchOperator<T> : ObservableBase<IBatchObserver<T>, BatchOp<T>>, IBatchOperand<T>, IBatchObservable<T> where T : IOperation
20
- // {
21
- // private Func<IBatchOperand<T>, IInitializationOperationsProvider<T>> _generateOperator;
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
- // public BatchOperator(ObservationContext context, Func<IBatchOperand<T>, IInitializationOperationsProvider<T>> generateOperator) : base(context)
26
- // {
27
- // _generateOperator = generateOperator;
28
- // }
23
+ _source = source;
24
+ _operand = operand;
29
25
 
30
- // protected override void OnFirstObserverAdded()
31
- // {
32
- // _active = true;
33
- // _operator = _generateOperator.Invoke(this);
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
- // protected override void OnLastObserverRemoved()
37
- // {
38
- // _active = false;
39
- // _operator?.Dispose();
40
- // _operator = null;
41
- // }
33
+ private void HandleSourceOperation(T operation)
34
+ {
35
+ _batchedOperations.Add(operation);
42
36
 
43
- // protected override void DisposeInternal()
44
- // {
45
- // _operator?.Dispose();
46
- // _operator = null;
47
- // }
37
+ if (_pending)
38
+ return;
48
39
 
49
- // void IBatchOperand<T>.EnqueuePendingOperation(IReadOnlyList<T> operation)
50
- // => EnqueuePendingOperation(new() { source = this, operations = operation });
40
+ _pending = true;
41
+ _source.context.RegisterPendingObserver(this);
42
+ _source.context.NotifyPendingObserversIfNecessary();
43
+ }
51
44
 
52
- // void IOperand.OnError(Exception error)
53
- // => OnError(error);
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
- // void IOperand.OnDisposed()
56
- // {
57
- // if (!_active)
58
- // return;
53
+ public void SendNext()
54
+ {
55
+ _pending = false;
59
56
 
60
- // Dispose();
61
- // }
57
+ var batch = _batchedOperations.ToArray();
58
+ _batchedOperations.Clear();
62
59
 
63
- // protected override IEnumerable<BatchOp<T>> GetInitializationOperations()
64
- // {
65
- // yield return new BatchOp<T>() { source = this, operations = _operator.GetInitializationOperations() };
66
- // }
60
+ _operand.EnqueueOperation(batch);
61
+ }
67
62
 
68
- // protected override void SendOperation(IBatchObserver<T> observer, BatchOp<T> operation)
69
- // => observer.OnNext(operation.operations);
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: 0ad77fb1c6773c540bd984e9eab9c4be
2
+ guid: d36db333036392248810c9ce317875ec
@@ -2,12 +2,12 @@ using System;
2
2
 
3
3
  namespace ObserveThing
4
4
  {
5
- public class CastValueObservable<T> : IDisposable
5
+ public class CastValueOperator<T> : IDisposable
6
6
  {
7
7
  private ObservableValue<T> _operand;
8
8
  private IDisposable _subscription;
9
9
 
10
- public CastValueObservable(IValueObservable source, ObservableValue<T> operand)
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 CastCollectionObservable<T> : IDisposable
29
+ public class CastCollectionOperator<T> : IDisposable
30
30
  {
31
31
  private ObservableCollection<T> _operand;
32
32
  private IDisposable _subscription;
33
33
 
34
- public CastCollectionObservable(ICollectionObservable source, ObservableCollection<T> operand)
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 CastListObservable<T> : IDisposable
54
+ public class CastListOperator<T> : IDisposable
55
55
  {
56
56
  private ObservableList<T> _operand;
57
57
  private IDisposable _subscription;
58
58
 
59
- public CastListObservable(IListObservable source, ObservableList<T> operand)
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 CastSetObservable<T> : IDisposable
79
+ public class CastSetOperator<T> : IDisposable
80
80
  {
81
81
  private ObservableSet<T> _operand;
82
82
  private IDisposable _subscription;
83
83
 
84
- public CastSetObservable(ISetObservable source, ObservableSet<T> operand)
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 CastDictionaryObservable<TKey, TValue> : IDisposable
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 CastDictionaryObservable(IDictionaryObservable source, ObservableDictionary<TKey, TValue> operand)
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 CombineObservable<T> : IInitializationOperationsProvider<T> where T : IOperation
6
+ public class CombineOperator<T> : IInitializationOperationsProvider<T>
7
7
  {
8
- private ISetObservable<IObservable<T>> _source;
9
- private Observable<T> _operand;
8
+ private ISetObservable<IEventStreamObservable<T>> _source;
9
+ private ObservableEventStream<T> _operand;
10
10
  private bool _disposeOnSourceEmpty;
11
11
  private uint _elementPriority;
12
- private Dictionary<IObservable<T>, IDisposable> _observables = new Dictionary<IObservable<T>, IDisposable>();
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 CombineObservable(ISetObservable<IObservable<T>> source, Observable<T> operand, bool disposeOnSourceEmpty = false)
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<IObservable<T>>(
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 Observer<T>(x => initOps.Add(x)));
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 _, IObservable<T> observable)
44
+ private void HandleElementAdded(uint _, IEventStreamObservable<T> observable)
45
45
  {
46
46
  _observables.Add(
47
47
  observable,
48
- observable.Subscribe(new Observer<T>(
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 _, IObservable<T> observable)
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 CombineValueObservable<T1, T2> : IDisposable
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 CombineValueObservable(IValueObservable<T1> source1, IValueObservable<T2> source2, ObservableValue<(T1, T2)> operand)
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 CombineValueObservable<T1, T2, T3> : IDisposable
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 CombineValueObservable(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, ObservableValue<(T1, T2, T3)> operand)
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 CombineValueObservable<T1, T2, T3, T4> : IDisposable
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 CombineValueObservable(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, IValueObservable<T4> source4, ObservableValue<(T1, T2, T3, T4)> operand)
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 CombineValueObservable<T1, T2, T3, T4, T5> : IDisposable
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 CombineValueObservable(IValueObservable<T1> source1, IValueObservable<T2> source2, IValueObservable<T3> source3, IValueObservable<T4> source4, IValueObservable<T5> source5, ObservableValue<(T1, T2, T3, T4, T5)> operand)
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 CombineValueObservable<T1, T2, T3, T4, T5, T6> : IDisposable
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 CombineValueObservable(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)
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 CombineValueObservable<T1, T2, T3, T4, T5, T6, T7> : IDisposable
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 CombineValueObservable(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)
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 ConcatObservable<T> : IDisposable
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 ConcatObservable(ICollectionObservable<T> source1, ICollectionObservable<T> source2, ObservableCollection<T> operand)
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 ContainsObservable<T> : IDisposable
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 ContainsObservable(ICollectionObservable<T> source, IValueObservable<T> value, ObservableValue<bool> operand)
13
+ public ContainsOperator(ICollectionObservable<T> source, IValueObservable<T> value, ObservableValue<bool> operand)
14
14
  {
15
15
  _operand = operand;
16
16
  _subscriptions = new ComposedDisposable(
@@ -0,0 +1,2 @@
1
+ fileFormatVersion: 2
2
+ guid: 615c00bc7abd3b1409f4ad93b93ae25a
@@ -2,12 +2,12 @@ using System;
2
2
 
3
3
  namespace ObserveThing
4
4
  {
5
- public class CountObservable<T> : IDisposable
5
+ public class CountOperator<T> : IDisposable
6
6
  {
7
7
  private ObservableValue<int> _operand;
8
8
  private IDisposable _subscriptions;
9
9
 
10
- public CountObservable(ICollectionObservable<T> source, ObservableValue<int> operand)
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 DistinctObservable<T> : IDisposable
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 DistinctObservable(ICollectionObservable<T> source, ObservableSet<T> operand)
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 CollectionOperator<T> : Operator<ObservableCollection<T>>, ICollectionObservable<T>
5
+ public class CollectionOperatorFactory<T> : OperatorFactory<ObservableCollection<T>>, ICollectionObservable<T>
6
6
  {
7
- public CollectionOperator(ObservationContext context, Func<ObservableCollection<T>, IDisposable> generateOperator) : base(context, generateOperator) { }
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 DictionaryOperator<TKey, TValue> : Operator<ObservableDictionary<TKey, TValue>>, IDictionaryObservable<TKey, TValue>
6
+ public class DictionaryOperatorFactory<TKey, TValue> : OperatorFactory<ObservableDictionary<TKey, TValue>>, IDictionaryObservable<TKey, TValue>
7
7
  {
8
- public DictionaryOperator(ObservationContext context, Func<ObservableDictionary<TKey, TValue>, IDisposable> generateOperator) : base(context, generateOperator) { }
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 ObservableOperator<T> : IObservable<T>, IInitializationOperationsProvider<T> where T : IOperation
6
+ public class EventStreamOperatorFactory<T> : IEventStreamObservable<T>, IInitializationOperationsProvider<T>
7
7
  {
8
8
  public ObservationContext context { get; }
9
9
 
10
- private Func<Observable<T>, IInitializationOperationsProvider<T>> _generateOperator;
11
- protected Observable<T> _observable { get; private set; }
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<IObserverBase> _observers = new List<IObserverBase>();
14
+ private List<IObserver> _observers = new List<IObserver>();
15
15
  private bool _disposed;
16
16
 
17
- public ObservableOperator(ObservationContext context, Func<Observable<T>, IInitializationOperationsProvider<T>> generateOperator)
17
+ public EventStreamOperatorFactory(ObservationContext context, Func<ObservableEventStream<T>, IInitializationOperationsProvider<T>> factory)
18
18
  {
19
19
  this.context = context;
20
- _generateOperator = 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(IObserverBase observer)
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 Observable<T>(context, this);
45
+ _observable = new ObservableEventStream<T>(context, this);
46
46
  _operator = _generateOperator(_observable);
47
47
  }
48
48
 
49
- protected void RemoveObserver(IObserverBase observer)
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(IObserver<T> observer, bool immediate = false, uint? priority = null)
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 ListOperator<T> : Operator<ObservableList<T>>, IListObservable<T>
5
+ public class ListOperatorFactory<T> : OperatorFactory<ObservableList<T>>, IListObservable<T>
6
6
  {
7
- public ListOperator(ObservationContext context, Func<ObservableList<T>, IDisposable> generateOperator) : base(context, generateOperator) { }
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 Operator<T> where T : class, IDisposable, new()
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> _generateOperator;
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<IObserverBase> _observers = new List<IObserverBase>();
14
+ private List<IObserver> _observers = new List<IObserver>();
15
15
  private bool _disposed;
16
16
 
17
- public Operator(ObservationContext context, Func<T, IDisposable> generateOperator)
17
+ public OperatorFactory(ObservationContext context, Func<T, IDisposable> factory)
18
18
  {
19
19
  this.context = context;
20
- _generateOperator = generateOperator;
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(IObserverBase observer)
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 = _generateOperator(_observable);
46
+ _operator = _factory(_observable);
47
47
  }
48
48
 
49
- protected void RemoveObserver(IObserverBase observer)
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 SetOperator<T> : Operator<ObservableSet<T>>, ISetObservable<T>
5
+ public class SetOperatorFactory<T> : OperatorFactory<ObservableSet<T>>, ISetObservable<T>
6
6
  {
7
- public SetOperator(ObservationContext context, Func<ObservableSet<T>, IDisposable> generateOperator) : base(context, generateOperator) { }
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
  }