浏览代码

fix transform

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

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


Debug.Log("val = " + val);
});
}
private void test10()
{
Stream<int> numbers = Stream<int>.fromIterable(new List<int> {0, 1, 2, 2, 3, 4, 5, 5});
var transformer = StreamTransformer<int, string>.fromHandlers(handleData: (val, sink) =>
{
sink.add("My number is " + val);
});
numbers.transform(transformer).listen(val =>
{
Debug.Log("val = " + val);
});
}
test9();
test10();
return new Container();
}
}

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


return streamConsumer.addStream(this).then((_) => streamConsumer.close(), (_) => FutureOr.nil);
}
Stream<S> transform<S>(StreamTransformer<T, S> streamTransformer) where S : class {
public Stream<S> transform<S>(StreamTransformer<T, S> streamTransformer) where S : class {
return streamTransformer.bind(this);
}

6
com.unity.uiwidgets/Runtime/async/stream_transformers.cs


namespace Unity.UIWidgets.async {
class _EventSinkWrapper<T> : EventSink<T> {
_EventSink<object> _sink;
_EventSink<T> _sink;
internal _EventSinkWrapper(_EventSink<object> _sink) {
internal _EventSinkWrapper(_EventSink<T> _sink) {
this._sink = _sink;
}

Action<T> onData, Action<object, string> onError, Action onDone, bool cancelOnError)
// We set the adapter's target only when the user is allowed to send data.
: base(onData, onError, onDone, cancelOnError) {
_EventSinkWrapper<T> eventSink = new _EventSinkWrapper<T>((_EventSink<object>) this);
_EventSinkWrapper<T> eventSink = new _EventSinkWrapper<T>(this);
_transformerSink = mapper(eventSink);
_subscription =
source.listen(_handleData, onError: _handleError, onDone: _handleDone);

正在加载...
取消
保存