Set Search Input in Ngrx Store

This commit is contained in:
Sebastian
2020-06-24 11:30:37 +02:00
parent 03e441f5af
commit b0eae87a5d

View File

@@ -1,23 +1,31 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngxs/store';
import { Store as NgxsStore } from '@ngxs/store';
import { SetShelfSearch } from 'apps/sales/src/app/core/store/actions/process.actions';
import { ShelfSearch } from 'apps/sales/src/app/core/models/shelf-search.modal';
import { BranchSelectors } from 'apps/sales/src/app/core/store/selectors/branch.selector';
import { SearchStateFacade } from 'apps/sales/src/app/store/customer';
@Injectable({ providedIn: 'root' })
export class ShelfStoreFacadeService {
constructor(private store: Store) {}
constructor(
private ngxsStore: NgxsStore,
private storeFacade: SearchStateFacade
) {}
get branchnumber(): string {
return this.store.selectSnapshot(BranchSelectors.getUserBranch);
return this.ngxsStore.selectSnapshot(BranchSelectors.getUserBranch);
}
setShelfSearch(input: string) {
this.store.dispatch(
/** NGXXS Store */
this.ngxsStore.dispatch(
new SetShelfSearch(<ShelfSearch>{
input,
branchnumber: this.branchnumber,
})
);
/** NEW NgRx Store */
this.storeFacade.setInput(input);
}
}