Flutter, Bloc, 为什么MapEventToState中只使用Stream
Flutter, Bloc, why only Stream used in MapEventToState
我查阅了很多 bloc 示例,但它们都只使用如下所示的流。
@override
Stream<SomeModel> mapEventToState(SomeEvent event) async* {
if (event is A event) {
//yield* calling stream function..
} else if (event is B event) {
//yield calling stream function..
//I have never seen a calling future function here.
//Even if it exists, it exists in this stream function, like in a nested form.
}
所以我想知道为什么只使用流。
另外,如果流很多,会不会有内存过载的副作用?
查看 Reactive Programming — Streams — BLoC 文章以获得关于流的最佳示例和解释以及使用它们的影响。
我查阅了很多 bloc 示例,但它们都只使用如下所示的流。
@override
Stream<SomeModel> mapEventToState(SomeEvent event) async* {
if (event is A event) {
//yield* calling stream function..
} else if (event is B event) {
//yield calling stream function..
//I have never seen a calling future function here.
//Even if it exists, it exists in this stream function, like in a nested form.
}
所以我想知道为什么只使用流。
另外,如果流很多,会不会有内存过载的副作用?
查看 Reactive Programming — Streams — BLoC 文章以获得关于流的最佳示例和解释以及使用它们的影响。