英文:
How to pass instance of one Bloc instance to another bloc , so that we can use BlocA state change in BlocB
问题
如何将一个 Bloc 实例的实例传递给另一个 Bloc,以便我们可以在 BlocB 中使用 BlocA 的状态变化
英文:
How do pass an instance of one Bloc instance to another bloc, so that we can use BlocA state change in BlocB
答案1
得分: 1
以下是要翻译的内容:
"Technically just pass it as a parameter. But you shouldn't. It is not recommended by the author of Flutter Bloc."
"建议仅将其作为参数传递。但不应该这样做。这不被Flutter Bloc的作者推荐。"
"The recommended solution is to let blocs communicate via either the presentation layer (the UI) by using BlocListeners, OR via streams from injected repositories."
"建议的解决方案是通过使用BlocListeners或通过从注入的存储库中的流来让blocs在表示层(UI)之间进行通信。"
"There is a segment on this in the documentation:
https://bloclibrary.dev/#/architecture?id=bloc-to-bloc-communication"
"文档中有关此的部分:
https://bloclibrary.dev/#/architecture?id=bloc-to-bloc-communication"
英文:
Well, technically just pass it as a parameter. But you shouldn't. It is not recommended by the author of Flutter Bloc.
The recommended solution is to let blocs communicate via either the presentation layer (the UI) by using BlocListeners, OR via streams from injected repositories.
There is a segment on this in the documentation:
https://bloclibrary.dev/#/architecture?id=bloc-to-bloc-communication
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论