15.0.1 • Published 1 year ago

ngrx-watch-component-store v15.0.1

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

NgrxWatchComponentStore

Simplify debugging of ngrx's ComponentStore

npm i ngrx-watch-component-store

Introduction

The goal of this library is to display log on each ComponentStore state update. Here is what you can get in your Chrome DevTools:

https://github.com/Odonno/ngrx-watch-component-store/blob/main/images/logs.png?raw=true

How to use?

Simply add WatchComponentState decorator on each ComponentStore in your app. See for yourself:

import { Injectable } from "@angular/core";
import { ComponentStore } from "@ngrx/component-store";
import { WatchComponentState } from "ngrx-watch-component-store";

@Injectable()
@WatchComponentState()
export class AppStore extends ComponentStore<AppState> {
  constructor() {
    super(initialAppState);
  }

  // selectors
  readonly count$ = this.select((state) => state.count);

  // updaters
  readonly increment = this.updater((state) => ({ count: state.count + 1 }));
  readonly decrement = this.updater((state) => ({ count: state.count - 1 }));
  readonly reset = this.updater(() => initialAppState);
}
15.0.0

1 year ago

15.0.1

1 year ago

14.0.0

1 year ago

1.0.0

1 year ago

0.1.1

2 years ago

0.1.0

2 years ago