- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
CoreModule 是一个预先加载的模块,包含应用程序启动时所需的状态。
import * as fromCore from './state/core.reducer';
@NgModule({
...
imports: [
StoreModule.forRoot({ core: fromCore.reducer }),
import * as fromDocument from './state/document.reducer';
@NgModule({
...
imports: [
StoreModule.forFeature('document', fromDocument.reducer),
import * as fromDocument from './state/document.reducer';
constructor(private store: Store<fromDocument.State>) { }
import * as fromCore from '../../core/state/core.reducer';
export interface State extends fromCore.State {
document: DocumentState;
}
this.user$ = this.store.select(fromCore.getUser);
最佳答案
具体点
在您提到的特定情况下,键入将有助于 select
的过载。将映射函数作为参数,例如this.store.select(s => ....)
.
不过,NgRx 仍然允许您进行无类型选择。 GitHub上的相关讨论:https://github.com/ngrx/store/issues/60
一般来说
来自 TypeScript 和其他花哨的东西的强类型(公平地说,所有编程语言的大多数特性)不是为了
user.namme
而不是
user.name
在代码的一个模糊的、被遗忘的部分中,这将导致一连串的错误。想象一下,它只向用户显示一些“未定义”和“登录错误”,在一个陌生的地方,并且只有当他按照一定的顺序执行 5 个非常具体的操作时,有点难以追溯和重现。
关于angular - 在 NgRx 中强类型化存储的目的是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60575758/
我已经建立了这个IStore: export interface IStore { user: IUser; sources: ISourceRedux; } 其中IUser是: export
store.select()发出先前的存储状态。 是否可以订阅从“此刻开始”的更改,而无需获取先前的商店值(value)? 最佳答案 如果您对第一个发出的值不感兴趣,则应该可以使用 skip 运算符:
我已将我的 ngrx 代码更新到版本 8(使用 Action Creator 等),但我现在不知道如何在 NgRx Store DevTools 中使用 Dispatcher。 在我能够发送这样的操作
我正在开发一个新的 angular 4 plus @ngrx 4 项目。 我希望对加载的数据具有搜索功能。 例如,所有联系人信息都已加载到组件中。 联系人列表将过滤与搜索文本匹配的联系人姓名。 Ple
我正在使用 Ngrx 和 Angular2 构建一个移动应用程序。当用户从我的应用程序中注销时,我想清除商店?谁能知道该怎么做? 最佳答案 您应该在每个 reducer 中有一个明确的操作,这将清理商
我看到很多代码示例,其中 store.dispatch() 调用直接发生在 Angular 组件中。让一个愚蠢的 Angular 组件访问整个 Store 不是很糟糕吗?为什么不将所有的 Action
ngrx 的支持者声称 (here for example),您可以并且应该将所有应用程序状态保存在单个 Store 中。这表明 @ngrx/Store 可以用于缓存,因为缓存的内容是一种应用程序状态
我的应用程序在调度某个 Action 时没有调度某些 Action 或某些效果没有被调用,这有问题(请参阅 ngrx effect not being called when action is di
下面的代码片段有什么作用?取自此 file . export const getCollectionLoading = createSelector(getCollectionState, fromC
如果在同一个商店上分派(dispatch)多个操作: store.dispatch(new SomeAction()); store.dispatch(new SomeOtherAction());
我试图了解 typeof 效果在 ngrx 中是如何工作的,如果我在我的应用程序模块中声明: .... @NgModule({ imports: [ EffectsModule
任何人都可以建议在角度应用程序中使用 ngrx 进行状态管理时如何控制台记录状态。我已经浏览了 ngrx-store-logger,但是文档并不清楚如何创建元 reducer 和使用这个库。 最佳答案
我一直在阅读ngrx示例应用程序的代码并找到两个函数调用 createFeatureSelector('auth'); 和 createSelector(selectAuthState,(state:
我正在使用 Angular 8 和 NGRX 8。我有一个操作: export const loadEnvironment = createAction( LicencingActionTypes
我正在使用 Angular 8 和 NGRX 8。我有一个操作: export const loadEnvironment = createAction( LicencingActionTypes
以下示例取自 @ngrx example . 我以这种方式理解这个 observable。第一map函数获取 payload这是要添加的书,再次由mergeMap处理它保存到数据库的位置。 原码:
我目前正在使用 NgRx Data 对我项目中的几个实体执行 CRUD 操作。现在,我必须开发分页。因此,REST API 响应将如下所示: { "page": 1, "per_pag
如何在 NGRX 中访问(读取)另一个 reducer 中的 reducer 状态?这是一个与 this 非常相似的问题.NGRX 是否为此提供任何其他解决方案? 最佳答案 我在考虑做类似的事情时偶然
我正在尝试按属性过滤掉有效负载数据。 //reducer.ts case MessagesActionTypes.LOAD_Message_SUCCESS: { console.lo
我有效果类,我想根据路由器参数 ID 加载详细信息 @Effect() getDetails$ = this.actions$.ofType(DetailActions.GET_DETAILS).
我是一名优秀的程序员,十分优秀!