浏览代码

add multistream test case

/main
Xingwei Zhu 3 年前
当前提交
db54610c
共有 2 个文件被更改,包括 38 次插入2 次删除
  1. 38
      Samples/UIWidgetsSamples_2019_4/Assets/Editor/Tests/Stream/TestMain.cs
  2. 2
      com.unity.uiwidgets/Runtime/async/stream.cs

38
Samples/UIWidgetsSamples_2019_4/Assets/Editor/Tests/Stream/TestMain.cs


Debug.Log("val = " + val);
});
}
/**
* Test Stream.multi
*/
private void test13()
{
var log = new List<string>();
var index = 1;
var multi = Stream<List<int>>.multi(c =>
{
var id = index++;
log.Add($"{id}");
for (var i = 0; i < id + 1; i++)
{
c.add(new List<int>{id, i});
}
c.close();
});
void logList(List<int> l)
{
log.Add($"{l.first()}-{l.last()}");
}
Future.wait<object>(new List<Future> {multi.forEach(logList), multi.forEach(logList)}).whenComplete(
() =>
{
foreach (var str in log)
{
Debug.Log(str);
}
}
);
}
test12();
test13();
return new Container();
}
}

2
com.unity.uiwidgets/Runtime/async/stream.cs


return future.to<bool>();
}
Future forEach(Action<T> action) {
public Future forEach(Action<T> action) {
_Future future = new _Future();
StreamSubscription<T> subscription = null;
subscription = listen(

正在加载...
取消
保存