Skip to content

Instantly share code, notes, and snippets.

@yKimisaki
Last active July 2, 2021 06:12
Show Gist options
  • Save yKimisaki/c44f4e08d5f4c2c63f3819f27a273738 to your computer and use it in GitHub Desktop.
Save yKimisaki/c44f4e08d5f4c2c63f3819f27a273738 to your computer and use it in GitHub Desktop.
using System;
using UniRx;
using UnityEngine;
public class KyubuTest : MonoBehaviour
{
public void Start()
{
var rp = new ReactiveProperty<int>(1);
Observable.Timer(TimeSpan.FromSeconds(0.5)).Subscribe(_ => rp.Value = 2);
Observable.Timer(TimeSpan.FromSeconds(1.0)).Subscribe(_ => rp.Value = 3);
Observable.Timer(TimeSpan.FromSeconds(1.5)).Subscribe(_ => rp.Value = 4);
Observable.Timer(TimeSpan.FromSeconds(2.0)).Subscribe(_ => rp.Value = 5);
Observable.Timer(TimeSpan.FromSeconds(2.5)).Subscribe(_ => rp.Value = 6);
// RaiseOnNextの変更を入れたらこうなる
rp.Skip(2).First().Subscribe(x =>
{
Debug.Log($"v1 = {x}"); // 3
rp.Skip(2).First().Subscribe(y =>
{
Debug.Log($"v2 = {y}"); // 5
rp.Skip(2).First().Subscribe(x => Debug.Log($"v3 = {x}")); // こない
});
});
// 現状
rp.Skip(2).First().Subscribe(x =>
{
Debug.Log($"v1 = {x}"); // 3
rp.Skip(2).First().Subscribe(y =>
{
Debug.Log($"v2 = {y}"); // 4
rp.Skip(2).First().Subscribe(x => Debug.Log($"v3 = {x}")); // 5
});
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment