Skip to content

Instantly share code, notes, and snippets.

View Protonz's full-sized avatar

Proton One Protonz

View GitHub Profile
@Protonz
Protonz / UniRx_MergePropertyTest.cs
Last active February 1, 2017 00:18
Merging multiple ReactiveProperties into a single output signal when any one of them changes
[Test]
public void MergePropertyTest() {
// Create an IEnumerable list of reactive proeprties
List<ReactiveProperty<int>> rxPropertyList = new List<ReactiveProperty<int>>();
// Add a couple reactive properties
rxPropertyList.Add(new ReactiveProperty<int>(1));
rxPropertyList.Add(new ReactiveProperty<int>(2));
// Convert the IEnumerable list to an observable stream
@Protonz
Protonz / UniRx_ReactiveCommandTest.cs
Created December 12, 2016 10:32
Testing out the ReactiveCommand
public class UniRxUnitTests {
[Test]
public void ReactiveCommandTest_2() {
// Arrange
ReactiveProperty<long> CurrentHp = new ReactiveProperty<long>(100);
// Only allow when the player is dead
// ReactiveCommand Resurrect = CurrentHp.Select(hp=> return hp <= 0).ToReactiveCommand();
int canExecuteCalled = 0;
ReactiveCommand Resurrect = CurrentHp.Select(hp=> { canExecuteCalled++; return hp <= 0; }).ToReactiveCommand();