Flutter,Bloc,为什么MapEventToState中只使用Stream

问题描述

我查找了很多 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 文章,了解有关流及其使用影响的最佳示例和说明。