UniRx使用
IObservable<bool> ExistsAsync (DatabaseReference reference)
{
var subject = new AsyncSubject<bool> ();
reference.GetValueAsync ().ContinueWith (x => {
if (x.IsFaulted) {
Debug.LogError ("Fail to read guildInfo");
// エラーを飛ばす
subject.Dispose ();
} else if (x.IsCompleted) {
DataSnapshot snapshot = x.Result;
subject.OnNext (snapshot.Exists);
subject.OnCompleted ();
}
});
return subject;
}
取得には早くても0.2秒,遅いと1.4秒ほどかかった.
再生直後だと,1秒近くかかりましたが,基本的に0.2秒ほどでした.