gpt4 book ai didi

dart - AngularDart 与 Redux

转载 作者:行者123 更新时间:2023-12-03 02:53:29 25 4
gpt4 key购买 nike

在检查 redux.dart 和 built_redux 以及 angulardart 的文档时,我看到了两种从我的应用程序中的任何组件“连接”到商店的不同方式:

  • 在服务中实例化一个存储对象,然后注入(inject)任何组件并选择我们关心的子状态
  • 实例化到根组件,然后通过 @Input() 字段将状态和调度程序传递给子组件。

  • 所以我很困惑,其中哪一种(或其他方式?)是最有效的,并且会给我正确的舞台管理?

    最佳答案

    • instantiating into the root component and then passing state and dispatchers to the children through @Input() fields.


    这在技术上是可行的,但看起来很奇怪、麻烦且效率低下。

    在 Angular 中使用依赖注入(inject)是一种方法:

    • Instantiating a store object in a service and then injecting in any component and selecting the substate we

    关于dart - AngularDart 与 Redux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50178745/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com