ngrx-store

How to get the correct slice data using selectors for multiple pieces of state and use them inside component | ngRx | Redux | Angular 6 | typescript

时间秒杀一切 提交于 2019-12-13 03:25:30
问题 I am going to create an application using angular 6 and ngrx v6. I have created the following app state. app.module.ts StoreModule.forRoot({'user': userReducer, 'events': eventsReducer}), app.state.ts import { UsersState } from '@app/reducers/users.reducers'; import { EventsState } from '@app/reducers/events.reducers'; export interface AppState{ user:UsersState, events:EventsState } users.reducers.ts export interface UsersState { lastInteractionTime: number, bookmarksId: object } const

Property 'replaceReducer' does not exist on type 'Store<State>' After upgrading @ngrx/store

大憨熊 提交于 2019-12-13 03:23:53
问题 In my Angular app, I have a function which replaces replaces the current reducer used by the Store. However, after upgrade from @ngrx/store v2.2.2 to v6.1.0, "replaceReducer" function seems to have been removed from the Store interface. I've gone through the NGRX migration guide (https://github.com/ngrx/platform/blob/master/MIGRATION.md) hoping to find a possible solution or an alternative way to go around the issue but I can't find any reference to the removed "replaceReducer" function

Angular ngrx migration error “Property 'select' does not exist on type 'Observable<State>'”

落爺英雄遲暮 提交于 2019-12-12 17:12:57
问题 I am attempting to migrate an existing application from ngrx v2 to v4, and am having a bit of trouble with a scenario I do not see covered in the migration document. The migration document has you remove @ngrx/core, but I am not sure what to do with my reducers that import from @ngrx/core/add/operator/select and select from an Observable. I am getting the error "Property 'select' does not exist on type 'Observable'" from all of the reducers. /actions/action-with-payload.ts -- Workaround for

changing the store state from component ngrx

こ雲淡風輕ζ 提交于 2019-12-12 16:54:52
问题 I'm using selectors to select from the store this.quizz = this.store.select(getSelectedQuizz); I use the async pipe to read from this observable like this in the template [*ngIf="quizz | async; let quizz"] I only define the action and I didn't modify the reducer yet the template is a form when I save the form I dispatch an update action which is only defined in my actions with readonly but I notice that when ever I save the form and dispatch the action the store changed and I didn't specify

@Ngrx/store: how to query models with relationships

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 13:35:24
问题 I an Angular 2 app using Redux (with @ngrx/store), I have modeled the store this way: { modelA: { ids: [1, 2], entities: { 1: { name: "name modelA 1" }, 2: { name: "name modelA 2" } } }, modelB: { ids: [5, 8], entities: { 5: { name: "name modelB 5" }, 8: { name: "name modelA 8" }, 9: { name: "name modelA 9" } } } } Basically, I have 2 types of objects: modelA and modelB. This is ok for now. But I can't find which is the best way to write a relationship between then, representing something

Issue in implementing the Ngrx Store service into my component

无人久伴 提交于 2019-12-12 05:39:55
问题 After a user tried to help with an issue regarding that post: My stackoverflow old post I am now trying to implement the Ngrx store using Ngrx store github to help me solve multiples input/output event. Just after my constructor I have an error: counter is not assignable to parameter of type (state: Appstate) => boolean : child.ts : import { Component, Input, Output, EventEmitter } from '@angular/core'; import { UserService3 } from '../user3.service'; import { Store } from '@ngrx/store';

ngrx: get value from the store before load page

一笑奈何 提交于 2019-12-11 19:05:34
问题 I have page component, inside that I'm displaying some data from ngrx/store : // profile.ts user$: User = this.store.select('user') // profile.html ... <div *ngIf="user$ | async; let user"> <div>{{user.id}}</div> <div>{{user.email}}</div> </div> This works, but I don't like that it initially loads the page without data, and then after 1 sec add this data from the user$ . I understand this is how it should be - because I'm using async pipe, but I want to change it. What options do I have? Can

current state in ngrx angular

余生长醉 提交于 2019-12-11 09:10:19
问题 Hi new to ngrx i am trying implement a smaple example for ngrx with angular but i have implemented everything not able to get the current state after service call So can please help me to get the current state and how many to get the state in ngrx as newbie to ngrx and correct if there are coding needs to improved in other places I have added the stackblitz link https://stackblitz.com/edit/angular-gvjoju 回答1: The reducers added to StoreModule.forRoot() must be an actionmap, for example:

ngrx- default values being overwritten through spread operator?

此生再无相见时 提交于 2019-12-11 08:46:03
问题 I am working on an ngrx selector that converts a section of the state tree into a view model. As a simple example, in my state tree I have an array of manager . Thus I have the following setup for my state tree, and view model- export interface Manager { id: string, name: string } export interface AppState { managers: Manager[] } export interface ManagersVM { byId: {[key: string]: Manager}, allIds: string[] } export const defaultManagersVM: ManagersVM { byId: {}, allIds: [] }; Then in my

Karma unit test / STORE - state undefined

别说谁变了你拦得住时间么 提交于 2019-12-11 00:24:20
问题 Everything works OK when running the application but in the Account unit test it seems like none or my states have been initiated. Is there anything obvious I am doing wrong? Here is the error. Test error: The create selector in index.js is returning a function with undefined parameters but only during karma tests. Account.component.ts import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core'; import * as fromAuth from '../../../auth/store/reducers'; import { Store