Created
October 5, 2017 09:39
-
-
Save kyubuns/572b95f3b97b125d3270fb5ddeb79d90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UniRx; | |
namespace Dev | |
{ | |
public class Sandbox : MonoBehaviour | |
{ | |
void Start() | |
{ | |
Debug.Log("start"); | |
AsyncMessageBroker.Default.Subscribe<TestArgs>(x => | |
{ | |
return Observable | |
.Timer(TimeSpan.FromSeconds(3)) | |
.ForEachAsync(_ => Debug.Log($"1: {x.Value}")); | |
}); | |
AsyncMessageBroker.Default.Subscribe<TestArgs>(x => | |
{ | |
return Observable | |
.Timer(TimeSpan.FromSeconds(2)) | |
.ForEachAsync(_ => Debug.Log($"2: {x.Value}")); | |
}); | |
AsyncMessageBroker.Default.Subscribe<IHoge>(x => | |
{ | |
return Observable | |
.Timer(TimeSpan.FromSeconds(1.5f)) | |
.ForEachAsync(_ => Debug.Log($"3: {x.Value}")); | |
}); | |
AsyncMessageBroker.Default.PublishAsync(new TestArgs{ Value = 3000 }) | |
.Subscribe(_ => | |
{ | |
UnityEngine.Debug.Log("called all subscriber completed"); | |
}); | |
} | |
} | |
public interface IHoge | |
{ | |
int Value { get; } | |
} | |
public class TestArgs : IHoge | |
{ | |
public int Value { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment