繁体   English   中英

ngrx DevTools 中的 logOnly 选项有什么用?

[英]What's the use of the logOnly option in ngrx DevTools?

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

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

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

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

根据文档

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

带有指向扩展功能的链接。

基于此,我们可以假设将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
    }
})

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

使用logOnly可以保证状态的完整性

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

暂无
暂无

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

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