ngrx

@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

NGRX/Store payload type confusion

天涯浪子 提交于 2019-12-12 11:09:54
问题 I have the following actions: export const ActionTypes = { CREATE_OH: type('[ORDERHEAD] Create Orderhead'), MODIFY_SELECTED_OH: type('[ORDERHEAD] Select Orderhead'), }; export class CreateOHAction implements Action { type = ActionTypes.CREATE_OH constructor(public payload: OrderHead[]) { } } export type Actions = CreateOHAction | SelectOHAction; With the following base reducer setup export interface State { orderids: string[]; entities: { [orderID: string]: OrderHead }; selectedOhID: string |

Guidance on how to make a theming mechanism that effects all components in Angular?

喜欢而已 提交于 2019-12-12 10:31:57
问题 Question: I need guidance on how to write a mechanism in Angular to set the "Look and Feel" of components globally in my application. Please note, I'm trying to learn @ngrx/platform and I thought this would be an interesting design constraint; however, I'm willing to let it go if it just doesn't make sense. Breakdown: I have an application in progress with many components. Each component in my application has currently 3 possible "look and feels(L&F)": Morning (sepia) Afternoon (white)

Ngrx effects on lower version of typescript doesn't work

天大地大妈咪最大 提交于 2019-12-12 10:07:40
问题 I have an Ionic 3 App where I use ngrx/store and ngrx/effects. But each time I try to run the app it sais this error below: TypeScript Error A computed property name in a type literal must directly refer to a built- in symbol. ...: Cannot find name 'any'. which refers to this folder in my node modules node_modules/@ngrx/effects/src/on_run_effect.d.ts to this block of code below: export declare function isOnRunEffects(sourceInstance: { [onRunEffectsKey]?: onRunEffectsFn; }): sourceInstance is

How to create a factory that returns anonymous classes that implement a generic interface

∥☆過路亽.° 提交于 2019-12-12 03:35:58
问题 We are using ngrx with Angular/TypeScript. To add some type safety to Actions, we created the following export interface TypedAction<T> extends Action { type: string; payload: T; } export class ExtensionRegistrationAction implements TypedAction<ExtensionRegistrationPayload> { readonly type = ExtensionActionTypes.REGISTER_EXTENSION; constructor(public payload: ExtensionRegistrationPayload) {} } export class ExtensionRegistrationSucceededAction implements TypedAction<void> { readonly type =

How to refactor to remove the control statements from @ngrx effects?

浪尽此生 提交于 2019-12-12 01:48:28
问题 I have a if control statement in an effect to return an action in the case of data has been retrieved from a service, if not return another action to get data from another Web API . It is a chained effects operation where there is another effect to handle the LOADFROMWEBAPI action. Is there a better way and avoid the if control statement, and return one action like LoadFromWebAPI only? Where the action SearchCompleteAction can be returned is the question - in effect or reducer? @Effect()

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

NgRx : dispatch one event from a store to another

别说谁变了你拦得住时间么 提交于 2019-12-11 17:49:02
问题 I'm beginning to use @ngrx and I'm facing an issue to which I can't seem to find an answer. I illustrated it in this stackblitz : when a player picks a race, the specialty should be set back to undefined. At first I thought I could use the reducer, but it doesn't have knowledge of the store without injection. How should I approach this issue ? (Note : this is a reproductible example, I know I can put a second dispatch in my functions. What I want is to do it automatically) Related code :

Share Angular 5 variables with SCSS

纵然是瞬间 提交于 2019-12-11 15:23:41
问题 Right now I'm working on Angular 5 application for our 3 clients. We have made some of needed implementation but considering layout for them there is a problem. All three clients have different demands for application colors and fonts. In my SASS file i have something like this: //currently selected company $currently-selected-company: company1; //here I set current brand but I want to make it load after rest response. //There are default values for variables below so there won't be any null.

reducers is not being called when using --aot=true

不羁的心 提交于 2019-12-11 14:58:21
问题 I have angular 4.4.3 project with ngrx 4.0.3 and angular-cli 1.1.2. Everything is OK when i'm not using aot option, but when i'm using --aot=true I can see that reducers not being called (because I cannot see console output 'REDUCER FIRED'): action: import { Post } from '../models'; import {Action as NgRxAction} from '@ngrx/store'; export interface Action extends NgRxAction { payload?: any; } @Injectable() export class PostActions { static LOAD_POSTS = '[Post] Load Posts'; loadPosts(): Action