Skip to content

Commit

Permalink
refactor(example-app): remove store generic (#2994)
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored Apr 12, 2021
1 parent d39b862 commit cdb5bd5
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class LoginPageComponent implements OnInit {
pending$ = this.store.select(fromAuth.selectLoginPagePending);
error$ = this.store.select(fromAuth.selectLoginPageError);

constructor(private store: Store<fromAuth.State>) {}
constructor(private store: Store) {}

ngOnInit() {}

Expand Down
4 changes: 1 addition & 3 deletions projects/example-app/src/app/auth/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ export function reducers(state: AuthState | undefined, action: Action) {
})(state, action);
}

export const selectAuthState = createFeatureSelector<State, AuthState>(
authFeatureKey
);
export const selectAuthState = createFeatureSelector<AuthState>(authFeatureKey);

export const selectAuthStatusState = createSelector(
selectAuthState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as fromAuth from '@example-app/auth/reducers';
providedIn: 'root',
})
export class AuthGuard implements CanActivate {
constructor(private store: Store<fromAuth.State>) {}
constructor(private store: Store) {}

canActivate(): Observable<boolean> {
return this.store.select(fromAuth.selectLoggedIn).pipe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import * as fromBooks from '@example-app/books/reducers';
export class CollectionPageComponent implements OnInit {
books$: Observable<Book[]>;

constructor(private store: Store<fromBooks.State>) {
constructor(private store: Store) {
this.books$ = store.select(fromBooks.selectBookCollection);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class FindBookPageComponent {
loading$: Observable<boolean>;
error$: Observable<string>;

constructor(private store: Store<fromBooks.State>) {
constructor(private store: Store) {
this.searchQuery$ = store.select(fromBooks.selectSearchQuery).pipe(take(1));
this.books$ = store.select(fromBooks.selectSearchResults);
this.loading$ = store.select(fromBooks.selectSearchLoading);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class SelectedBookPageComponent {
book$: Observable<Book>;
isSelectedBookInCollection$: Observable<boolean>;

constructor(private store: Store<fromBooks.State>) {
constructor(private store: Store) {
this.book$ = store.select(fromBooks.selectSelectedBook) as Observable<Book>;
this.isSelectedBookInCollection$ = store.select(
fromBooks.isSelectedBookInCollection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ViewBookPageActions } from '@example-app/books/actions';
export class ViewBookPageComponent implements OnDestroy {
actionsSubscription: Subscription;

constructor(store: Store<fromBooks.State>, route: ActivatedRoute) {
constructor(store: Store, route: ActivatedRoute) {
this.actionsSubscription = route.params
.pipe(map((params) => ViewBookPageActions.selectBook({ id: params.id })))
.subscribe((action) => store.dispatch(action));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as fromBooks from '@example-app/books/reducers';
})
export class BookExistsGuard implements CanActivate {
constructor(
private store: Store<fromBooks.State>,
private store: Store,
private googleBooks: GoogleBooksService,
private router: Router
) {}
Expand Down
2 changes: 1 addition & 1 deletion projects/example-app/src/app/books/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function reducers(state: BooksState | undefined, action: Action) {
* The createFeatureSelector function selects a piece of state from the root of the state object.
* This is used for selecting feature states that are loaded eagerly or lazily.
*/
export const selectBooksState = createFeatureSelector<State, BooksState>(
export const selectBooksState = createFeatureSelector<BooksState>(
booksFeatureKey
);

Expand Down
6 changes: 2 additions & 4 deletions projects/example-app/src/app/core/containers/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ import { LayoutActions } from '@example-app/core/actions';
Sign Out
</bc-nav-item>
</bc-sidenav>
<bc-toolbar (openMenu)="openSidenav()">
Book Collection
</bc-toolbar>
<bc-toolbar (openMenu)="openSidenav()"> Book Collection </bc-toolbar>
<router-outlet></router-outlet>
</bc-layout>
Expand All @@ -50,7 +48,7 @@ export class AppComponent {
showSidenav$: Observable<boolean>;
loggedIn$: Observable<boolean>;

constructor(private store: Store<fromRoot.State & fromAuth.State>) {
constructor(private store: Store) {
/**
* Selectors can be applied with the `select` operator which passes the state
* tree to the provided selector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class RouterEffects {

constructor(
private actions$: Actions,
private store: Store<fromRoot.State>,
private store: Store,
private titleService: Title
) {}
}
9 changes: 4 additions & 5 deletions projects/example-app/src/app/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const metaReducers: MetaReducer<State>[] = !environment.production
/**
* Layout Selectors
*/
export const selectLayoutState = createFeatureSelector<State, fromLayout.State>(
export const selectLayoutState = createFeatureSelector<fromLayout.State>(
fromLayout.layoutFeatureKey
);

Expand All @@ -80,9 +80,8 @@ export const selectShowSidenav = createSelector(
/**
* Router Selectors
*/
export const selectRouter = createFeatureSelector<
State,
fromRouter.RouterReducerState
>('router');
export const selectRouter = createFeatureSelector<fromRouter.RouterReducerState>(
'router'
);

export const { selectRouteData } = fromRouter.getSelectors(selectRouter);

0 comments on commit cdb5bd5

Please sign in to comment.