com.fofx.observething 1.0.0 → 1.1.0-dev.36048653905
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/README.md +1 -1
- package/Runtime/CollectionIdProvider.cs +71 -71
- package/Runtime/CollectionIdProvider.cs.meta +1 -1
- package/Runtime/IObservable.cs +66 -66
- package/Runtime/IObservable.cs.meta +1 -1
- package/Runtime/Implementations/Observable.cs +29 -29
- package/Runtime/Implementations/Observable.cs.meta +1 -1
- package/Runtime/Implementations/ObservableBase.cs +172 -172
- package/Runtime/Implementations/ObservableBase.cs.meta +1 -1
- package/Runtime/Implementations/ObservableCollection.cs +140 -140
- package/Runtime/Implementations/ObservableCollection.cs.meta +1 -1
- package/Runtime/Implementations/ObservableDictionary.cs +165 -165
- package/Runtime/Implementations/ObservableDictionary.cs.meta +1 -1
- package/Runtime/Implementations/ObservableList.cs +162 -162
- package/Runtime/Implementations/ObservableList.cs.meta +1 -1
- package/Runtime/Implementations/ObservableSet.cs +136 -136
- package/Runtime/Implementations/ObservableSet.cs.meta +1 -1
- package/Runtime/Implementations/ObservableValue.cs +58 -58
- package/Runtime/Implementations/ObservableValue.cs.meta +1 -1
- package/Runtime/Observables/BatchObservable.cs +71 -71
- package/Runtime/Observables/BatchObservable.cs.meta +1 -1
- package/Runtime/Observables/CastObservable.cs +127 -127
- package/Runtime/Observables/CastObservable.cs.meta +1 -1
- package/Runtime/Observables/CombineObservable.cs +95 -95
- package/Runtime/Observables/CombineObservable.cs.meta +1 -1
- package/Runtime/Observables/CombineValueObservable.cs +318 -318
- package/Runtime/Observables/CombineValueObservable.cs.meta +1 -1
- package/Runtime/Observables/ConcatObservable.cs +74 -74
- package/Runtime/Observables/ConcatObservable.cs.meta +1 -1
- package/Runtime/Observables/ContainsObservable.cs +70 -70
- package/Runtime/Observables/ContainsObservable.cs.meta +1 -1
- package/Runtime/Observables/CountObservable.cs +29 -29
- package/Runtime/Observables/CountObservable.cs.meta +1 -1
- package/Runtime/Observables/DistinctObservable.cs +54 -54
- package/Runtime/Observables/DistinctObservable.cs.meta +1 -1
- package/Runtime/Observables/FirstObservable.cs +52 -52
- package/Runtime/Observables/FirstObservable.cs.meta +1 -1
- package/Runtime/Observables/IndexOfObservable.cs +82 -82
- package/Runtime/Observables/IndexOfObservable.cs.meta +1 -1
- package/Runtime/Observables/OperationStreamObservable.cs +193 -193
- package/Runtime/Observables/OperationStreamObservable.cs.meta +1 -1
- package/Runtime/Observables/OrderByObservable.cs +115 -116
- package/Runtime/Observables/OrderByObservable.cs.meta +1 -1
- package/Runtime/Observables/SelectCollectionObservable.cs +28 -28
- package/Runtime/Observables/SelectCollectionObservable.cs.meta +1 -1
- package/Runtime/Observables/SelectListObservable.cs +28 -28
- package/Runtime/Observables/SelectListObservable.cs.meta +1 -1
- package/Runtime/Observables/SelectManyObservable.cs +77 -77
- package/Runtime/Observables/SelectManyObservable.cs.meta +1 -1
- package/Runtime/Observables/SelectValueObservable.cs +27 -27
- package/Runtime/Observables/SelectValueObservable.cs.meta +1 -1
- package/Runtime/Observables/SkipWhileObservable.cs +31 -31
- package/Runtime/Observables/SkipWhileObservable.cs.meta +1 -1
- package/Runtime/Observables/ThenObservable.cs +208 -208
- package/Runtime/Observables/ThenObservable.cs.meta +1 -1
- package/Runtime/Observables/ToDictionaryObservable.cs +35 -35
- package/Runtime/Observables/ToDictionaryObservable.cs.meta +1 -1
- package/Runtime/Observables/TrackObservable.cs +74 -74
- package/Runtime/Observables/TrackObservable.cs.meta +1 -1
- package/Runtime/Observables/UnwrapCollectionObservable.cs +63 -63
- package/Runtime/Observables/UnwrapCollectionObservable.cs.meta +1 -1
- package/Runtime/Observables/UnwrapListObservable.cs +69 -69
- package/Runtime/Observables/UnwrapListObservable.cs.meta +1 -1
- package/Runtime/Observables/UnwrapValueObservable.cs +55 -55
- package/Runtime/Observables/UnwrapValueObservable.cs.meta +1 -1
- package/Runtime/Observables/WhereObservable.cs +84 -84
- package/Runtime/Observables/WhereObservable.cs.meta +1 -1
- package/Runtime/Observables/WithPreviousObservable.cs +36 -36
- package/Runtime/Observables/WithPreviousObservable.cs.meta +1 -1
- package/Runtime/Observables.cs +466 -466
- package/Runtime/Observables.meta +8 -8
- package/Runtime/ObservationContext.cs +125 -125
- package/Runtime/ObservationContext.cs.meta +1 -1
- package/Runtime/Observers.cs +402 -402
- package/Runtime/Observers.cs.meta +1 -1
- package/Runtime/Operators/BatchOperator.cs +70 -70
- package/Runtime/Operators/BatchOperator.cs.meta +1 -1
- package/Runtime/Operators/CollectionOperator.cs +30 -30
- package/Runtime/Operators/CollectionOperator.cs.meta +1 -1
- package/Runtime/Operators/DictionaryOperator.cs +45 -45
- package/Runtime/Operators/DictionaryOperator.cs.meta +1 -1
- package/Runtime/Operators/IInitializationOperationsProvider.cs +10 -10
- package/Runtime/Operators/IInitializationOperationsProvider.cs.meta +1 -1
- package/Runtime/Operators/ListOperator.cs +44 -44
- package/Runtime/Operators/ListOperator.cs.meta +1 -1
- package/Runtime/Operators/ObservableOperator.cs +74 -74
- package/Runtime/Operators/ObservableOperator.cs.meta +1 -1
- package/Runtime/Operators/Operator.cs +65 -65
- package/Runtime/Operators/Operator.cs.meta +1 -1
- package/Runtime/Operators/SetOperator.cs +44 -44
- package/Runtime/Operators/SetOperator.cs.meta +1 -1
- package/Runtime/Operators/ValueOperator.cs +29 -29
- package/Runtime/Operators/ValueOperator.cs.meta +1 -1
- package/Runtime/Operators.meta +8 -8
- package/Runtime/PriorityQueue.cs +1095 -1095
- package/Runtime/PriorityQueue.cs.meta +1 -1
- package/Tests/CollectionObservableTests.cs +738 -738
- package/Tests/DictionaryObservableTests.cs +84 -84
- package/Tests/ListObservableTests.cs +147 -147
- package/Tests/ObservationContextTests.cs +359 -359
- package/Tests/ObservationContextTests.cs.meta +1 -1
- package/Tests/ValueObservableTests.cs +321 -321
- 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
|
package/Runtime/IObservable.cs
CHANGED
|
@@ -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
|