简体   繁体   English

在 Ionic 5 中使用 Ngrx DevTools

[英]Using Ngrx DevTools with Ionic 5

I am trying to follow this link to use the Ngrx DevTools.我正在尝试按照此链接使用 Ngrx DevTools。 But Ionic uses @ionic/angular-toolkit, and we need to enable the Ngrx Schematics which replaces that.但是 Ionic 使用 @ionic/angular-toolkit,我们需要启用 Ngrx Schematics 来替代它。 Is there a way to have both?有没有办法两者兼得?

Changes in Angular.json
  "cli": {
--"defaultCollection": "@ionic/angular-toolkit"
++"defaultCollection": "@ngrx/schematics"
},

@ionic/angular-toolkit: Angular Schematics and Builders for @ionic/angular apps @ionic/angular-toolkit: Angular @ionic/angular 应用程序的原理图和构建器

I was able to use the ngrx schematics to generate my stores for my Ionic 5 app by:我能够使用 ngrx 原理图为我的 Ionic 5 应用程序生成商店,方法是:

  1. installing the @ngrx/schematics and allowing them to replace the @ionic/angular-toolkit.安装@ngrx/schematics 并允许他们替换@ionic/angular-toolkit。
  2. running "ng generate store..."运行“ng generate store...”
  3. replacing the "defaultCollection" entry with "@ionic/angular-toolkit"用“@ionic/angular-toolkit”替换“defaultCollection”条目

This seemed to allow me to get it done -- until Ionic provides an update to their schematics for this.这似乎让我能够完成它——直到 Ionic 为此提供了对其原理图的更新。

Yes, this is a hack, and requires me to do this each time that I want to gen a store, but it allows me to use ngrx tools, would like to learn a cleaner way from someone!是的,这是一个 hack,每次我想创建一个商店时都要求我这样做,但它允许我使用 ngrx 工具,想向某人学习更清洁的方法!

  1. Install @ngrx/store-devtools安装 @ngrx/store-devtools
  2. Add "StoreDevtoolsModule.instrument({ maxAge: 30 })" in imports in app.module.ts在 app.module.ts 的导入中添加“StoreDevtoolsModule.instrument({ maxAge: 30 })”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM