How to pass instance of one Bloc instance to another bloc , so that we can use BlocA state change in BlocB

huangapple go评论68阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年2月10日 14:43:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/75407723.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定