Skip to content

Commit

Permalink
feat(plugins): add ngxs-reset-plugin and logger plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
marcjulian committed Nov 22, 2019
1 parent 18279b8 commit 699417e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
14 changes: 10 additions & 4 deletions integration/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { environment } from './../environments/environment';
import { CounterState } from './store/counter.state';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
Expand All @@ -11,12 +12,15 @@ import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { NgxsModule } from '@ngxs/store';
import {
NgxsAsyncStoragePluginModule,
STORAGE_ENGINE
NgxsAsyncStoragePluginModule
} from '@ngxs-labs/async-storage-plugin';
import { StorageService } from './services/storage.service';
import { IonicStorageModule } from '@ionic/storage';

import { NgxsResetPluginModule } from 'ngxs-reset-plugin';

import { NgxsLoggerPluginModule } from '@ngxs/logger-plugin';

@NgModule({
declarations: [AppComponent],
entryComponents: [],
Expand All @@ -26,7 +30,9 @@ import { IonicStorageModule } from '@ionic/storage';
AppRoutingModule,
IonicStorageModule.forRoot(),
NgxsModule.forRoot([CounterState]),
NgxsAsyncStoragePluginModule.forRoot(StorageService)
NgxsResetPluginModule.forRoot(),
NgxsAsyncStoragePluginModule.forRoot(StorageService),
NgxsLoggerPluginModule.forRoot({ disabled: environment.production })
],
providers: [
StatusBar,
Expand All @@ -35,4 +41,4 @@ import { IonicStorageModule } from '@ionic/storage';
],
bootstrap: [AppComponent]
})
export class AppModule {}
export class AppModule { }
19 changes: 12 additions & 7 deletions integration/app/home/home.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
</ion-header>

<ion-content padding>
<ng-container *ngIf="counter$ | async as counter">
<h1>{{ counter }}</h1>
</ng-container>
<ion-button (click)="increment()">Increment</ion-button>
<ion-button (click)="decrement()">Decrement</ion-button>
</ion-content>
<ng-container *ngIf="counter$ | async as counter">
<h1>{{ counter }}</h1>
</ng-container>
<ion-button (click)="increment()">Increment</ion-button>
<ion-button (click)="decrement()">Decrement</ion-button>


<ion-button (click)="resetState()">
Reset State
</ion-button>
</ion-content>
7 changes: 6 additions & 1 deletion integration/app/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { Select, Store } from '@ngxs/store';
import { CounterState, Increment, Decrement } from '../store/counter.state';
import { Observable } from 'rxjs';
import { StateResetAll } from 'ngxs-reset-plugin';

@Component({
selector: 'app-home',
Expand All @@ -12,7 +13,7 @@ export class HomePage {
@Select(CounterState)
public counter$: Observable<number>;

constructor(private store: Store) {}
constructor(private store: Store) { }

increment() {
this.store.dispatch(new Increment());
Expand All @@ -21,4 +22,8 @@ export class HomePage {
decrement() {
this.store.dispatch(new Decrement());
}

resetState() {
this.store.dispatch(new StateResetAll());
}
}
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
"@ionic-native/status-bar": "5.15.0",
"@ionic/angular": "4.10.2",
"@ionic/storage": "2.2.0",
"@ngxs/logger-plugin": "3.5.1",
"@ngxs/store": "3.5.1",
"core-js": "2.6.6",
"ngxs-reset-plugin": "1.2.0",
"rxjs": "6.5.2",
"zone.js": "0.8.26"
},
Expand Down

0 comments on commit 699417e

Please sign in to comment.