【问题标题】:What's the use of the logOnly option in ngrx DevTools?ngrx DevTools 中的 logOnly 选项有什么用?
【发布时间】:2018-08-08 07:10:01
【问题描述】:

我已阅读 https://github.com/ngrx/platform/tree/master/docs/store-devtools 的简约文档,并了解您可以按如下方式添加检测:

StoreDevtoolsModule.instrument({
  logOnly: environment.production
})

假设,如果 logOnly 标志为真,您的应用将以仅记录模式连接到 Redux DevTools 扩展,它的开销非常小,因为它不应该存储状态数据,而只记录操作名称在运行时发生。

但是在我的实验中,我仍然在ngrx DevTools面板中看到状态数据,那么使用logOnly:true有什么好处呢?

【问题讨论】:

标签: angular redux ngrx


【解决方案1】:

如果您在您发送的那个链接上scroll down a little bit,您将看到:

logOnly: boolean - 以仅日志模式连接到 Devtools 扩展。默认为 false 启用所有扩展功能。

带有extensions features的链接。

基于此我们可以假设将logOnly 设置为true 将关闭以下redux-devtools-extension 功能:

const composeEnhancers = composeWithDevTools({
    features: {
        pause: true, // start/pause recording of dispatched actions
        lock: true, // lock/unlock dispatching actions and side effects    
        persist: true, // persist states on page reloading
        export: true, // export history of actions in a file
        import: 'custom', // import history of actions from a file
        jump: true, // jump back and forth (time travelling)
        skip: true, // skip (cancel) actions
        reorder: true, // drag and drop actions in the history list 
        dispatch: true, // dispatch custom actions or action creators
        test: true // generate tests for the selected actions
    },
});

这非常适合生产环境,因为您可能不需要或不希望这些主要以开发为中心的功能在您的实时应用程序中运行。

【讨论】:

    【解决方案2】:

    使用logOnly保证状态的完整性

    您无法修改它,例如操作调度程序已关闭。在纯日志模式下,您可以查看日志,但不能修改它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-05
      • 2019-12-16
      • 2022-08-22
      • 2021-04-16
      • 2016-03-06
      • 2022-01-07
      • 2018-02-28
      • 1970-01-01
      相关资源
      最近更新 更多