浏览代码

fix nullable issue

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

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


Debug.Log("val = " + val);
});
}
/**
* Test StreamController
*/
private void test11()
{
StreamController<float> controller = StreamController<float>.create();
Stream<float> stream = controller.stream;
var value = 1f;
var timer = Timer.periodic(new TimeSpan(0, 0, 0, 1), (v) =>
{
value = value * 1.2f;
controller.add(value);
return null;
});
stream.listen((val) =>
{
if (val >= 2)
{
timer.cancel();
}
Debug.Log("value = " + val);
});
}
test10();
test11();
return new Container();
}
}

12
com.unity.uiwidgets/Runtime/async/stream_controller.cs


public static StreamController<T> broadcast(
Action onListen = null, Action onCancel = null, bool sync = false) {
return sync
? (StreamController<T>) new _SyncBroadcastStreamController<T>(() => onListen(), onCancel)
: new _AsyncBroadcastStreamController<T>(() => onListen(), () => {
onCancel();
? (StreamController<T>) new _SyncBroadcastStreamController<T>(() => onListen?.Invoke(), onCancel)
: new _AsyncBroadcastStreamController<T>(() => onListen?.Invoke(), () => {
onCancel?.Invoke();
return Future._nullFuture;
});
}

}
subscription._setPendingEvents(pendingEvents);
subscription._guardCallback(() => { _stream._runGuarded(() => onListen()); });
subscription._guardCallback(() => { _stream._runGuarded(() => onListen?.Invoke()); });
return subscription;
}

addState.pause();
}
_stream._runGuarded(() => onPause());
_stream._runGuarded(() => onPause?.Invoke());
}
public override void _recordResume(StreamSubscription<T> subscription) {

}
_stream._runGuarded(() => onResume());
_stream._runGuarded(() => onResume?.Invoke());
}
}

正在加载...
取消
保存