Skip to content

Commit d78e725

Browse files
committed
a few additional extensions and fixed BatchFrame
1 parent 1f5715b commit d78e725

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

Assets/Src/Scripts/Data/Linq/DataObservable.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Reactive.Data.Linq.Observables;
22
using System.Reactive.Linq;
3+
using System.Linq;
34

45
namespace System.Reactive.Data.Linq {
56
public static class DataObservable {
@@ -29,5 +30,28 @@ public static IObservable<Pair<T>> Pairwise<T>(this IObservable<T> source) {
2930
throw new ArgumentNullException(nameof(source));
3031
return new Pairwise<T>(source);
3132
}
33+
34+
/// <summary>
35+
/// same as Publish().RefCount()
36+
/// </summary>
37+
public static IObservable<T> Share<T>(this IObservable<T> source) {
38+
return source.Publish().RefCount();
39+
}
40+
41+
public static IObservable<TSource> Concat<TSource>(this IObservable<TSource> first, params IObservable<TSource>[] seconds) {
42+
if (first is null)
43+
throw new ArgumentNullException(nameof(first));
44+
if (seconds is null)
45+
throw new ArgumentNullException(nameof(seconds));
46+
return Observable.Concat(new[] { first }.Concat(seconds));
47+
}
48+
49+
public static IObservable<T> Merge<T>(this IObservable<T> first, params IObservable<T>[] seconds) {
50+
if (first is null)
51+
throw new ArgumentNullException(nameof(first));
52+
if (seconds is null)
53+
throw new ArgumentNullException(nameof(seconds));
54+
return Observable.Merge(new[] { first }.Concat(seconds));
55+
}
3256
}
3357
}

Assets/Src/Scripts/Unity/Linq/Observables/BatchFrame.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal sealed class _ : Sink<T, IList<T>> {
2525
private bool _isRunning;
2626
private bool _isCompleted;
2727
private bool _isDisposed;
28-
private List<T> _list;
28+
private List<T> _list = new List<T>();
2929

3030
public _(IObserver<IList<T>> observer, int frameCount, FrameCountType frameCountType) : base(observer) {
3131
_frameCount = frameCount;

Assets/Src/Scripts/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "com.system.reactive.unity",
3+
"displayName": "Reactive Extensions Enrichment for Unity",
4+
"version": "1.0.0",
5+
"unity": "2021.2",
6+
"description": "A minimalistic MVVM framework for the new Unity UI Toolkit build on EcsRx.",
7+
"keywords": [ "rx", "system", "unity" ],
8+
"category": "gui",
9+
"dependencies": {},
10+
"author": {
11+
"name": "Jonas Fischer",
12+
"email": "[email protected]",
13+
"url": "https://github.com/Cosmic-Shores/System.Reactive.Unity"
14+
}
15+
}

Assets/Src/Scripts/package.json.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ PlayerSettings:
200200
- {fileID: 0}
201201
- {fileID: 0}
202202
- {fileID: 0}
203+
- {fileID: 0}
203204
metroInputSource: 0
204205
wsaTransparentSwapchain: 0
205206
m_HolographicPauseOnTrackingLoss: 1

0 commit comments

Comments
 (0)