com.fofx.observething 1.0.0 → 1.1.0

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 (103) hide show
  1. package/README.md +1 -1
  2. package/Runtime/CollectionIdProvider.cs +71 -71
  3. package/Runtime/CollectionIdProvider.cs.meta +1 -1
  4. package/Runtime/IObservable.cs +66 -66
  5. package/Runtime/IObservable.cs.meta +1 -1
  6. package/Runtime/Implementations/Observable.cs +29 -29
  7. package/Runtime/Implementations/Observable.cs.meta +1 -1
  8. package/Runtime/Implementations/ObservableBase.cs +172 -172
  9. package/Runtime/Implementations/ObservableBase.cs.meta +1 -1
  10. package/Runtime/Implementations/ObservableCollection.cs +140 -140
  11. package/Runtime/Implementations/ObservableCollection.cs.meta +1 -1
  12. package/Runtime/Implementations/ObservableDictionary.cs +165 -165
  13. package/Runtime/Implementations/ObservableDictionary.cs.meta +1 -1
  14. package/Runtime/Implementations/ObservableList.cs +162 -162
  15. package/Runtime/Implementations/ObservableList.cs.meta +1 -1
  16. package/Runtime/Implementations/ObservableSet.cs +136 -136
  17. package/Runtime/Implementations/ObservableSet.cs.meta +1 -1
  18. package/Runtime/Implementations/ObservableValue.cs +58 -58
  19. package/Runtime/Implementations/ObservableValue.cs.meta +1 -1
  20. package/Runtime/Observables/BatchObservable.cs +71 -71
  21. package/Runtime/Observables/BatchObservable.cs.meta +1 -1
  22. package/Runtime/Observables/CastObservable.cs +127 -127
  23. package/Runtime/Observables/CastObservable.cs.meta +1 -1
  24. package/Runtime/Observables/CombineObservable.cs +95 -95
  25. package/Runtime/Observables/CombineObservable.cs.meta +1 -1
  26. package/Runtime/Observables/CombineValueObservable.cs +318 -318
  27. package/Runtime/Observables/CombineValueObservable.cs.meta +1 -1
  28. package/Runtime/Observables/ConcatObservable.cs +74 -74
  29. package/Runtime/Observables/ConcatObservable.cs.meta +1 -1
  30. package/Runtime/Observables/ContainsObservable.cs +70 -70
  31. package/Runtime/Observables/ContainsObservable.cs.meta +1 -1
  32. package/Runtime/Observables/CountObservable.cs +29 -29
  33. package/Runtime/Observables/CountObservable.cs.meta +1 -1
  34. package/Runtime/Observables/DistinctObservable.cs +54 -54
  35. package/Runtime/Observables/DistinctObservable.cs.meta +1 -1
  36. package/Runtime/Observables/FirstObservable.cs +52 -52
  37. package/Runtime/Observables/FirstObservable.cs.meta +1 -1
  38. package/Runtime/Observables/IndexOfObservable.cs +82 -82
  39. package/Runtime/Observables/IndexOfObservable.cs.meta +1 -1
  40. package/Runtime/Observables/OperationStreamObservable.cs +193 -193
  41. package/Runtime/Observables/OperationStreamObservable.cs.meta +1 -1
  42. package/Runtime/Observables/OrderByObservable.cs +115 -116
  43. package/Runtime/Observables/OrderByObservable.cs.meta +1 -1
  44. package/Runtime/Observables/SelectCollectionObservable.cs +28 -28
  45. package/Runtime/Observables/SelectCollectionObservable.cs.meta +1 -1
  46. package/Runtime/Observables/SelectListObservable.cs +28 -28
  47. package/Runtime/Observables/SelectListObservable.cs.meta +1 -1
  48. package/Runtime/Observables/SelectManyObservable.cs +77 -77
  49. package/Runtime/Observables/SelectManyObservable.cs.meta +1 -1
  50. package/Runtime/Observables/SelectValueObservable.cs +27 -27
  51. package/Runtime/Observables/SelectValueObservable.cs.meta +1 -1
  52. package/Runtime/Observables/SkipWhileObservable.cs +31 -31
  53. package/Runtime/Observables/SkipWhileObservable.cs.meta +1 -1
  54. package/Runtime/Observables/ThenObservable.cs +208 -208
  55. package/Runtime/Observables/ThenObservable.cs.meta +1 -1
  56. package/Runtime/Observables/ToDictionaryObservable.cs +35 -35
  57. package/Runtime/Observables/ToDictionaryObservable.cs.meta +1 -1
  58. package/Runtime/Observables/TrackObservable.cs +74 -74
  59. package/Runtime/Observables/TrackObservable.cs.meta +1 -1
  60. package/Runtime/Observables/UnwrapCollectionObservable.cs +63 -63
  61. package/Runtime/Observables/UnwrapCollectionObservable.cs.meta +1 -1
  62. package/Runtime/Observables/UnwrapListObservable.cs +69 -69
  63. package/Runtime/Observables/UnwrapListObservable.cs.meta +1 -1
  64. package/Runtime/Observables/UnwrapValueObservable.cs +55 -55
  65. package/Runtime/Observables/UnwrapValueObservable.cs.meta +1 -1
  66. package/Runtime/Observables/WhereObservable.cs +84 -84
  67. package/Runtime/Observables/WhereObservable.cs.meta +1 -1
  68. package/Runtime/Observables/WithPreviousObservable.cs +36 -36
  69. package/Runtime/Observables/WithPreviousObservable.cs.meta +1 -1
  70. package/Runtime/Observables.cs +466 -466
  71. package/Runtime/Observables.meta +8 -8
  72. package/Runtime/ObservationContext.cs +125 -125
  73. package/Runtime/ObservationContext.cs.meta +1 -1
  74. package/Runtime/Observers.cs +402 -402
  75. package/Runtime/Observers.cs.meta +1 -1
  76. package/Runtime/Operators/BatchOperator.cs +70 -70
  77. package/Runtime/Operators/BatchOperator.cs.meta +1 -1
  78. package/Runtime/Operators/CollectionOperator.cs +30 -30
  79. package/Runtime/Operators/CollectionOperator.cs.meta +1 -1
  80. package/Runtime/Operators/DictionaryOperator.cs +45 -45
  81. package/Runtime/Operators/DictionaryOperator.cs.meta +1 -1
  82. package/Runtime/Operators/IInitializationOperationsProvider.cs +10 -10
  83. package/Runtime/Operators/IInitializationOperationsProvider.cs.meta +1 -1
  84. package/Runtime/Operators/ListOperator.cs +44 -44
  85. package/Runtime/Operators/ListOperator.cs.meta +1 -1
  86. package/Runtime/Operators/ObservableOperator.cs +74 -74
  87. package/Runtime/Operators/ObservableOperator.cs.meta +1 -1
  88. package/Runtime/Operators/Operator.cs +65 -65
  89. package/Runtime/Operators/Operator.cs.meta +1 -1
  90. package/Runtime/Operators/SetOperator.cs +44 -44
  91. package/Runtime/Operators/SetOperator.cs.meta +1 -1
  92. package/Runtime/Operators/ValueOperator.cs +29 -29
  93. package/Runtime/Operators/ValueOperator.cs.meta +1 -1
  94. package/Runtime/Operators.meta +8 -8
  95. package/Runtime/PriorityQueue.cs +1095 -1095
  96. package/Runtime/PriorityQueue.cs.meta +1 -1
  97. package/Tests/CollectionObservableTests.cs +738 -738
  98. package/Tests/DictionaryObservableTests.cs +84 -84
  99. package/Tests/ListObservableTests.cs +147 -147
  100. package/Tests/ObservationContextTests.cs +359 -359
  101. package/Tests/ObservationContextTests.cs.meta +1 -1
  102. package/Tests/ValueObservableTests.cs +321 -321
  103. package/package.json +24 -24
package/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # Welcome!
1
+ # Welcome!
2
2
  **TODO**
@@ -1,72 +1,72 @@
1
- using System;
2
-
3
- namespace ObserveThing
4
- {
5
- public class CollectionIdProvider
6
- {
7
- private Func<uint, bool> _validateId;
8
- private bool _validateBeforeFirstLoop;
9
- private uint _nextId = 0;
10
- private bool _looped;
11
-
12
- public CollectionIdProvider(Func<uint, bool> validateId, bool validateBeforeFirstLoop = false)
13
- {
14
- _validateId = validateId;
15
- _validateBeforeFirstLoop = validateBeforeFirstLoop;
16
- }
17
-
18
- public uint GetUnusedId()
19
- {
20
- uint id = _nextId;
21
-
22
- if (_looped || _validateBeforeFirstLoop)
23
- {
24
- bool found = false;
25
-
26
- for (uint i = _nextId; i < uint.MaxValue; i++)
27
- {
28
- if (_validateId(i))
29
- {
30
- id = i;
31
- found = true;
32
- break;
33
- }
34
- }
35
-
36
- if (!found)
37
- {
38
- for (uint i = 0; i < _nextId; i++)
39
- {
40
- if (_validateId(i))
41
- {
42
- id = i;
43
- found = true;
44
- break;
45
- }
46
- }
47
-
48
- if (!found)
49
- throw new Exception("No valid ID found!");
50
- }
51
- }
52
-
53
- if (id == uint.MaxValue)
54
- {
55
- _nextId = 0;
56
- _looped = true;
57
- }
58
- else
59
- {
60
- _nextId = id + 1;
61
- }
62
-
63
- return id;
64
- }
65
-
66
- public void Reset()
67
- {
68
- _looped = false;
69
- _nextId = 0;
70
- }
71
- }
1
+ using System;
2
+
3
+ namespace ObserveThing
4
+ {
5
+ public class CollectionIdProvider
6
+ {
7
+ private Func<uint, bool> _validateId;
8
+ private bool _validateBeforeFirstLoop;
9
+ private uint _nextId = 0;
10
+ private bool _looped;
11
+
12
+ public CollectionIdProvider(Func<uint, bool> validateId, bool validateBeforeFirstLoop = false)
13
+ {
14
+ _validateId = validateId;
15
+ _validateBeforeFirstLoop = validateBeforeFirstLoop;
16
+ }
17
+
18
+ public uint GetUnusedId()
19
+ {
20
+ uint id = _nextId;
21
+
22
+ if (_looped || _validateBeforeFirstLoop)
23
+ {
24
+ bool found = false;
25
+
26
+ for (uint i = _nextId; i < uint.MaxValue; i++)
27
+ {
28
+ if (_validateId(i))
29
+ {
30
+ id = i;
31
+ found = true;
32
+ break;
33
+ }
34
+ }
35
+
36
+ if (!found)
37
+ {
38
+ for (uint i = 0; i < _nextId; i++)
39
+ {
40
+ if (_validateId(i))
41
+ {
42
+ id = i;
43
+ found = true;
44
+ break;
45
+ }
46
+ }
47
+
48
+ if (!found)
49
+ throw new Exception("No valid ID found!");
50
+ }
51
+ }
52
+
53
+ if (id == uint.MaxValue)
54
+ {
55
+ _nextId = 0;
56
+ _looped = true;
57
+ }
58
+ else
59
+ {
60
+ _nextId = id + 1;
61
+ }
62
+
63
+ return id;
64
+ }
65
+
66
+ public void Reset()
67
+ {
68
+ _looped = false;
69
+ _nextId = 0;
70
+ }
71
+ }
72
72
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: cd37155dde1a72c46bc7b0a73356e92f
@@ -1,66 +1,66 @@
1
- using System;
2
- using System.Collections.Generic;
3
-
4
- namespace ObserveThing
5
- {
6
- public interface IObservable<out T> where T : IOperation
7
- {
8
- ObservationContext context { get; }
9
- IDisposable Subscribe(IObserver<T> observer, bool immediate = default, uint? priority = default);
10
- }
11
-
12
- public interface IValueObservable : IObservable<IOperation>
13
- {
14
- IDisposable Subscribe(IValueObserver observer, bool immediate = default, uint? priority = default);
15
- }
16
-
17
- public interface IValueObservable<out T> : IValueObservable
18
- {
19
- IDisposable Subscribe(IValueObserver<T> observer, bool immediate = default, uint? priority = default);
20
- }
21
-
22
- public interface ICollectionObservable : IObservable<IOperation>
23
- {
24
- IDisposable Subscribe(ICollectionObserver observer, bool immediate = default, uint? priority = default);
25
- }
26
-
27
- public interface ICollectionObservable<out T> : ICollectionObservable
28
- {
29
- IDisposable Subscribe(ICollectionObserver<T> observer, bool immediate = default, uint? priority = default);
30
- }
31
-
32
- public interface IListObservable : ICollectionObservable
33
- {
34
- IDisposable Subscribe(IListObserver observer, bool immediate = default, uint? priority = default);
35
- }
36
-
37
- public interface IListObservable<out T> : IListObservable, ICollectionObservable<T>
38
- {
39
- IDisposable Subscribe(IListObserver<T> observer, bool immediate = default, uint? priority = default);
40
- }
41
-
42
- public interface ISetObservable : ICollectionObservable
43
- {
44
- IDisposable Subscribe(ISetObserver observer, bool immediate = default, uint? priority = default);
45
- }
46
-
47
- public interface ISetObservable<out T> : ISetObservable, ICollectionObservable<T>
48
- {
49
- IDisposable Subscribe(ISetObserver<T> observer, bool immediate = default, uint? priority = default);
50
- }
51
-
52
- public interface IDictionaryObservable : ICollectionObservable
53
- {
54
- IDisposable Subscribe(IDictionaryObserver observer, bool immediate = default, uint? priority = default);
55
- }
56
-
57
- public interface IDictionaryObservable<TKey, TValue> : IDictionaryObservable, ICollectionObservable<KeyValuePair<TKey, TValue>>
58
- {
59
- IDisposable Subscribe(IDictionaryObserver<TKey, TValue> observer, bool immediate = default, uint? priority = default);
60
- }
61
-
62
- // public interface IBatchObservable<out T> : IObservable<IOperation> where T : IOperation
63
- // {
64
- // public IDisposable Subscribe(IBatchObserver<T> observer, bool immediate = false, uint? priority = default);
65
- // }
66
- }
1
+ using System;
2
+ using System.Collections.Generic;
3
+
4
+ namespace ObserveThing
5
+ {
6
+ public interface IObservable<out T> where T : IOperation
7
+ {
8
+ ObservationContext context { get; }
9
+ IDisposable Subscribe(IObserver<T> observer, bool immediate = default, uint? priority = default);
10
+ }
11
+
12
+ public interface IValueObservable : IObservable<IOperation>
13
+ {
14
+ IDisposable Subscribe(IValueObserver observer, bool immediate = default, uint? priority = default);
15
+ }
16
+
17
+ public interface IValueObservable<out T> : IValueObservable
18
+ {
19
+ IDisposable Subscribe(IValueObserver<T> observer, bool immediate = default, uint? priority = default);
20
+ }
21
+
22
+ public interface ICollectionObservable : IObservable<IOperation>
23
+ {
24
+ IDisposable Subscribe(ICollectionObserver observer, bool immediate = default, uint? priority = default);
25
+ }
26
+
27
+ public interface ICollectionObservable<out T> : ICollectionObservable
28
+ {
29
+ IDisposable Subscribe(ICollectionObserver<T> observer, bool immediate = default, uint? priority = default);
30
+ }
31
+
32
+ public interface IListObservable : ICollectionObservable
33
+ {
34
+ IDisposable Subscribe(IListObserver observer, bool immediate = default, uint? priority = default);
35
+ }
36
+
37
+ public interface IListObservable<out T> : IListObservable, ICollectionObservable<T>
38
+ {
39
+ IDisposable Subscribe(IListObserver<T> observer, bool immediate = default, uint? priority = default);
40
+ }
41
+
42
+ public interface ISetObservable : ICollectionObservable
43
+ {
44
+ IDisposable Subscribe(ISetObserver observer, bool immediate = default, uint? priority = default);
45
+ }
46
+
47
+ public interface ISetObservable<out T> : ISetObservable, ICollectionObservable<T>
48
+ {
49
+ IDisposable Subscribe(ISetObserver<T> observer, bool immediate = default, uint? priority = default);
50
+ }
51
+
52
+ public interface IDictionaryObservable : ICollectionObservable
53
+ {
54
+ IDisposable Subscribe(IDictionaryObserver observer, bool immediate = default, uint? priority = default);
55
+ }
56
+
57
+ public interface IDictionaryObservable<TKey, TValue> : IDictionaryObservable, ICollectionObservable<KeyValuePair<TKey, TValue>>
58
+ {
59
+ IDisposable Subscribe(IDictionaryObserver<TKey, TValue> observer, bool immediate = default, uint? priority = default);
60
+ }
61
+
62
+ // public interface IBatchObservable<out T> : IObservable<IOperation> where T : IOperation
63
+ // {
64
+ // public IDisposable Subscribe(IBatchObserver<T> observer, bool immediate = false, uint? priority = default);
65
+ // }
66
+ }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: 3b1531a1eddae4c4790263212a4adfb5
@@ -1,30 +1,30 @@
1
-
2
- using System.Collections.Generic;
3
-
4
- namespace ObserveThing
5
- {
6
- public class Observable<T> : ObservableBase<IObserver<T>, T> where T : IOperation
7
- {
8
- private IInitializationOperationsProvider<T> _initializationOperationsProvider;
9
-
10
- public Observable(ObservationContext context, IInitializationOperationsProvider<T> initializationOperationsProvider) : base(context)
11
- {
12
- _initializationOperationsProvider = initializationOperationsProvider;
13
- }
14
-
15
- protected override IEnumerable<T> GetInitializationOperations()
16
- {
17
- if (_initializationOperationsProvider == null)
18
- yield break;
19
-
20
- foreach (var op in _initializationOperationsProvider.GetInitializationOperations())
21
- yield return op;
22
- }
23
-
24
- protected override void SendOperation(IObserver<T> observer, T operation)
25
- => observer.OnNext(operation);
26
-
27
- public void EnqueueOperation(T operation)
28
- => EnqueuePendingOperation(operation);
29
- }
1
+
2
+ using System.Collections.Generic;
3
+
4
+ namespace ObserveThing
5
+ {
6
+ public class Observable<T> : ObservableBase<IObserver<T>, T> where T : IOperation
7
+ {
8
+ private IInitializationOperationsProvider<T> _initializationOperationsProvider;
9
+
10
+ public Observable(ObservationContext context, IInitializationOperationsProvider<T> initializationOperationsProvider) : base(context)
11
+ {
12
+ _initializationOperationsProvider = initializationOperationsProvider;
13
+ }
14
+
15
+ protected override IEnumerable<T> GetInitializationOperations()
16
+ {
17
+ if (_initializationOperationsProvider == null)
18
+ yield break;
19
+
20
+ foreach (var op in _initializationOperationsProvider.GetInitializationOperations())
21
+ yield return op;
22
+ }
23
+
24
+ protected override void SendOperation(IObserver<T> observer, T operation)
25
+ => observer.OnNext(operation);
26
+
27
+ public void EnqueueOperation(T operation)
28
+ => EnqueuePendingOperation(operation);
29
+ }
30
30
  }
@@ -1,2 +1,2 @@
1
- fileFormatVersion: 2
1
+ fileFormatVersion: 2
2
2
  guid: 9e6b02c6340fb034384039c77d32f7a3