Testing Angular component extending an abstract class

Issue I have this setup for a number of components: @Directive() export abstract class BaseComponent implements OnInit { @Select(PortalState.portal) public portalState: Observable<PortalModel>; public portal: PortalModel; protected ngUnsubscribe: Subject<void> = new Subject(); constructor( protected someService: SomeService, protected route: ActivatedRoute ){ }

Continue reading

NgXs @selector doesn't support async functions

Issue Inside my NGXS store I have the following async selector @Selector() static async mainState(store: IMyStore): Promise<IMyState> { return this.getActiveState(store); } If I now subscribe to this selector @Select(MyStore.mainState) state$: Observable<IMyState>; If I subscribe to this stream I receive promises

Continue reading

Ngxs – How do I chain actions?

Issue I want to do something like this for my registration. When clicking the register button, this will be executed: this.store.dispatch(new Register(user)) .subscribe(response => { localStorage.setItem(‘token’, JSON.stringify(response.token)); let redirectUrl = this.store.dispatch(new RegisterSuccess(response)); if (redirectUrl) { this.router.navigate([redirectUrl]); } else { this.router.navigate([‘/home’]);

Continue reading

Deleting an object in Angular NGXS

Issue I have a problem deleting a comment on my post. How would you do it? I’m using the Angular NGXS state management. Pls see this link CLICK THIS LINK onDeleteComment(commentId: number){ this.store.dispatch(new DeleteComment(commentId)); } @Action(DeleteComment) deleteComment( ctx: StateContext<PostStateModel>, {

Continue reading