Dart 流
2021-02-03 20:27:26 0 举报
Dart 中的Stream结构
作者其他创作
大纲/内容
Sink<T>
+ void add(T data);+ void close();
私_StreamController<T>
- int _state = _STATE_INITIAL;
+ operation1(params):returnType- operation2(params)- operation3()
私_AsyncStreamControllerDispatch<T>
私_ControllerSubscription<T>
私_StreamControllerLifecycle<T> _controller;
- void _onResume() ;- void _onPause()- Future<void>? _onCancel()
私_StreamControllerLifecycle<T>
私_SyncBroadcastStreamController<T>
StreamConsumer<S>
+ Future addStream(Stream<S> stream);+ Future close();
私_EventSink<T>
私_BufferingStreamSubscription<T>
- int _state;- _DataHandler<T> _onData;- _DoneHandler _onDone;- Function _onError;- Future? _cancelFuture;
实现StreamSubscription中的方法,维护状态。
StreamController<T>
+ Stream<T> stream ;+ Function() onListen;+ Function() onPause;+ Function() onResume;+ Function() onCancel;+ StreamSink<T> sink;+ bool isClosed;+ bool isPaused;+ bool hasListener;+ bool done;
私_StreamControllerBase<T>
私_EventDispatch<T>
私_SyncStreamControllerDispatch<T>
SynchronousStreamController<T>
Stream<T>
私_AsyncBroadcastStreamController<T>
私_BroadcastSubscription<T>
- _BroadcastSubscription<T>? _next;- _BroadcastSubscription<T>? _previous;
- bool _expectsEvent(int eventId);- void _toggleEventId();
私_SyncStreamController<T>
+ 混入_SyncStreamControllerDispatch<T>
私_AsyncStreamController<T>
+ 混入_AsyncStreamControllerDispatch<T>
StreamSubscription<T>
+ void onData(void handleData(T data)?);+ void onError(Function? handleError);+ void onDone(void handleDone()?);+ void pause([Future<void>? resumeSignal]);+ void resume();+ Future<void> cancel();+ bool isPaused;
私_BroadcastStreamController<T>
- Function()? onListen- Function()? onCancel- int _state;- _BroadcastSubscription<T>? _firstSubscription;- _BroadcastSubscription<T>? _lastSubscription;
+ Stream<T> get stream => new _BroadcastStream<T>(this);+ StreamSink<T> get sink => new _StreamSinkWrapper<T>(this);+ 实现其他方法
EventSink<T>
StreamSink<S>
+ Future close();+ Future get done;
0 条评论
回复 删除
下一页