在 RxDart 中处理主题 - Flutter Blocs
这听起来可能很幼稚,但我想知道我们是否需要在与Blocs合作时明确调用Dispose方法?因此,通常我会做类似的事情:
- 创建一个集团提供商
- 定义BLOC类并初始化行为/发布主题
- 创建一个dispose方法,我们关闭流。
现在,问题是我们需要在某个地方明确调用此Dispose方法吗?还是集团提供商自动为我们做到这一点?
您的帮助将不胜感激。谢谢。
This may sound naive but I wanted to know if we explicitly need to call the dispose method while working with blocs ? So usually I do something like this :
- Create a bloc provider
- Define the bloc class and initialise the behaviour/publish subjects
- Create a dispose method where we close the streams.
Now, the question is that do we need to explicitly call this dispose method somewhere ? Or does bloc providers automatically do it for us ??
Your help shall be highly appreciated. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用我的库:https://pub.dev/packages/flutter_bloc_pattern,它提供
BaseBloc
、DisposeCallbackBaseBloc
、RxStreamBuilder
示例
You can use my lib: https://pub.dev/packages/flutter_bloc_pattern, which provides
BaseBloc
,DisposeCallbackBaseBloc
,RxStreamBuilder
Example