From 92a6b20c1e0312658145a76283b8769113651223 Mon Sep 17 00:00:00 2001 From: Jason Hodges Date: Tue, 14 May 2019 06:02:06 -0600 Subject: [PATCH] refactor(example): use barrel import for book module (#1850) Closes #1684 --- .../src/app/books/actions/book.actions.ts | 3 +- .../app/books/actions/books-api.actions.ts | 3 +- .../books/actions/collection-api.actions.ts | 3 +- .../actions/selected-book-page.actions.ts | 3 +- .../src/app/books/books-routing.module.ts | 13 +++-- .../example-app/src/app/books/books.module.ts | 54 ++++++++++++------- .../components/book-authors.component.ts | 2 +- .../books/components/book-detail.component.ts | 5 +- .../components/book-preview-list.component.ts | 3 +- .../components/book-preview.component.ts | 3 +- .../src/app/books/components/index.ts | 39 ++------------ .../collection-page.component.spec.ts | 20 ++++--- .../containers/collection-page.component.ts | 3 +- .../find-book-page.component.spec.ts | 23 ++++---- .../containers/find-book-page.component.ts | 3 +- .../src/app/books/containers/index.ts | 4 ++ .../selected-book-page.component.spec.ts | 15 +++--- .../selected-book-page.component.ts | 9 ++-- .../view-book-page.component.spec.ts | 15 +++--- .../app/books/effects/book.effects.spec.ts | 7 +-- .../src/app/books/effects/book.effects.ts | 7 +-- .../books/effects/collection.effects.spec.ts | 16 +++--- .../app/books/effects/collection.effects.ts | 7 ++- .../src/app/books/effects/index.ts | 2 + .../example-app/src/app/books/guards/index.ts | 1 + projects/example-app/src/app/books/index.ts | 1 + .../example-app/src/app/books/models/index.ts | 1 + .../app/books/reducers/books.reducer.spec.ts | 2 +- .../src/app/books/reducers/books.reducer.ts | 9 ++-- .../app/books/reducers/collection.reducer.ts | 6 +-- .../src/app/books/reducers/index.ts | 2 +- .../services/book-storage.service.spec.ts | 4 +- .../app/core/services/book-storage.service.ts | 11 ++-- .../app/core/services/google-books.service.ts | 3 +- 34 files changed, 166 insertions(+), 136 deletions(-) create mode 100644 projects/example-app/src/app/books/containers/index.ts create mode 100644 projects/example-app/src/app/books/effects/index.ts create mode 100644 projects/example-app/src/app/books/guards/index.ts create mode 100644 projects/example-app/src/app/books/index.ts create mode 100644 projects/example-app/src/app/books/models/index.ts diff --git a/projects/example-app/src/app/books/actions/book.actions.ts b/projects/example-app/src/app/books/actions/book.actions.ts index 258943810d..7518ae7ede 100644 --- a/projects/example-app/src/app/books/actions/book.actions.ts +++ b/projects/example-app/src/app/books/actions/book.actions.ts @@ -1,5 +1,6 @@ import { createAction, props } from '@ngrx/store'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; export const loadBook = createAction( '[Book Exists Guard] Load Book', diff --git a/projects/example-app/src/app/books/actions/books-api.actions.ts b/projects/example-app/src/app/books/actions/books-api.actions.ts index ee9ee2f51e..392c9aa466 100644 --- a/projects/example-app/src/app/books/actions/books-api.actions.ts +++ b/projects/example-app/src/app/books/actions/books-api.actions.ts @@ -1,5 +1,6 @@ import { createAction, props } from '@ngrx/store'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; export const searchSuccess = createAction( '[Books/API] Search Success', diff --git a/projects/example-app/src/app/books/actions/collection-api.actions.ts b/projects/example-app/src/app/books/actions/collection-api.actions.ts index 5cf1ec8853..17f31a3922 100644 --- a/projects/example-app/src/app/books/actions/collection-api.actions.ts +++ b/projects/example-app/src/app/books/actions/collection-api.actions.ts @@ -1,5 +1,6 @@ import { createAction, props } from '@ngrx/store'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; /** * Add Book to Collection Actions diff --git a/projects/example-app/src/app/books/actions/selected-book-page.actions.ts b/projects/example-app/src/app/books/actions/selected-book-page.actions.ts index f81fca4060..591fdf1b45 100644 --- a/projects/example-app/src/app/books/actions/selected-book-page.actions.ts +++ b/projects/example-app/src/app/books/actions/selected-book-page.actions.ts @@ -1,5 +1,6 @@ import { createAction, props } from '@ngrx/store'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; /** * Add Book to Collection Action diff --git a/projects/example-app/src/app/books/books-routing.module.ts b/projects/example-app/src/app/books/books-routing.module.ts index a7ca393e48..32776c2814 100644 --- a/projects/example-app/src/app/books/books-routing.module.ts +++ b/projects/example-app/src/app/books/books-routing.module.ts @@ -1,9 +1,12 @@ import { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; -import { FindBookPageComponent } from '@example-app/books/containers/find-book-page.component'; -import { ViewBookPageComponent } from '@example-app/books/containers/view-book-page.component'; -import { CollectionPageComponent } from '@example-app/books/containers/collection-page.component'; -import { BookExistsGuard } from '@example-app/books/guards/book-exists.guard'; +import { RouterModule, Routes } from '@angular/router'; + +import { + CollectionPageComponent, + FindBookPageComponent, + ViewBookPageComponent, +} from '@example-app/books/containers'; +import { BookExistsGuard } from '@example-app/books/guards'; export const routes: Routes = [ { path: 'find', component: FindBookPageComponent }, diff --git a/projects/example-app/src/app/books/books.module.ts b/projects/example-app/src/app/books/books.module.ts index cd78dee030..217adb950b 100644 --- a/projects/example-app/src/app/books/books.module.ts +++ b/projects/example-app/src/app/books/books.module.ts @@ -1,26 +1,48 @@ -import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { StoreModule } from '@ngrx/store'; +import { NgModule } from '@angular/core'; + import { EffectsModule } from '@ngrx/effects'; +import { StoreModule } from '@ngrx/store'; -import { ComponentsModule } from '@example-app/books/components'; -import { BookEffects } from '@example-app/books/effects/book.effects'; -import { CollectionEffects } from '@example-app/books/effects/collection.effects'; +import { BooksRoutingModule } from '@example-app/books/books-routing.module'; +import { + BookAuthorsComponent, + BookDetailComponent, + BookPreviewComponent, + BookPreviewListComponent, + BookSearchComponent, +} from '@example-app/books/components'; +import { + CollectionPageComponent, + FindBookPageComponent, + SelectedBookPageComponent, + ViewBookPageComponent, +} from '@example-app/books/containers'; +import { BookEffects, CollectionEffects } from '@example-app/books/effects'; -import { FindBookPageComponent } from '@example-app/books/containers/find-book-page.component'; -import { ViewBookPageComponent } from '@example-app/books/containers/view-book-page.component'; -import { SelectedBookPageComponent } from '@example-app/books/containers/selected-book-page.component'; -import { CollectionPageComponent } from '@example-app/books/containers/collection-page.component'; +import { reducers } from '@example-app/books/reducers'; import { MaterialModule } from '@example-app/material'; +import { PipesModule } from '@example-app/shared/pipes'; -import { reducers } from '@example-app/books/reducers'; -import { BooksRoutingModule } from '@example-app/books/books-routing.module'; +export const COMPONENTS = [ + BookAuthorsComponent, + BookDetailComponent, + BookPreviewComponent, + BookPreviewListComponent, + BookSearchComponent, +]; + +export const CONTAINERS = [ + FindBookPageComponent, + ViewBookPageComponent, + SelectedBookPageComponent, + CollectionPageComponent, +]; @NgModule({ imports: [ CommonModule, MaterialModule, - ComponentsModule, BooksRoutingModule, /** @@ -40,12 +62,8 @@ import { BooksRoutingModule } from '@example-app/books/books-routing.module'; * whether they are registered once or multiple times. */ EffectsModule.forFeature([BookEffects, CollectionEffects]), + PipesModule, ], - declarations: [ - FindBookPageComponent, - ViewBookPageComponent, - SelectedBookPageComponent, - CollectionPageComponent, - ], + declarations: [COMPONENTS, CONTAINERS], }) export class BooksModule {} diff --git a/projects/example-app/src/app/books/components/book-authors.component.ts b/projects/example-app/src/app/books/components/book-authors.component.ts index 4179312904..fa68185e8c 100644 --- a/projects/example-app/src/app/books/components/book-authors.component.ts +++ b/projects/example-app/src/app/books/components/book-authors.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; -import { Book } from '@example-app/books/models/book'; +import { Book } from '@example-app/books/models'; @Component({ selector: 'bc-book-authors', diff --git a/projects/example-app/src/app/books/components/book-detail.component.ts b/projects/example-app/src/app/books/components/book-detail.component.ts index cc4d0e76eb..ed747a577b 100644 --- a/projects/example-app/src/app/books/components/book-detail.component.ts +++ b/projects/example-app/src/app/books/components/book-detail.component.ts @@ -1,5 +1,6 @@ -import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { Book } from '@example-app/books/models/book'; +import { Component, EventEmitter, Input, Output } from '@angular/core'; + +import { Book } from '@example-app/books/models'; @Component({ selector: 'bc-book-detail', diff --git a/projects/example-app/src/app/books/components/book-preview-list.component.ts b/projects/example-app/src/app/books/components/book-preview-list.component.ts index 3b9e63d2e6..1b90a47d25 100644 --- a/projects/example-app/src/app/books/components/book-preview-list.component.ts +++ b/projects/example-app/src/app/books/components/book-preview-list.component.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; @Component({ selector: 'bc-book-preview-list', diff --git a/projects/example-app/src/app/books/components/book-preview.component.ts b/projects/example-app/src/app/books/components/book-preview.component.ts index 26b41d6bb1..b1bb8c7237 100644 --- a/projects/example-app/src/app/books/components/book-preview.component.ts +++ b/projects/example-app/src/app/books/components/book-preview.component.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; @Component({ selector: 'bc-book-preview', diff --git a/projects/example-app/src/app/books/components/index.ts b/projects/example-app/src/app/books/components/index.ts index 3d9e8b69c8..4e4a30c6eb 100644 --- a/projects/example-app/src/app/books/components/index.ts +++ b/projects/example-app/src/app/books/components/index.ts @@ -1,34 +1,5 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { ReactiveFormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; - -import { BookAuthorsComponent } from '@example-app/books/components/book-authors.component'; -import { BookDetailComponent } from '@example-app/books/components/book-detail.component'; -import { BookPreviewComponent } from '@example-app/books/components/book-preview.component'; -import { BookPreviewListComponent } from '@example-app/books/components/book-preview-list.component'; -import { BookSearchComponent } from '@example-app/books/components/book-search.component'; - -import { PipesModule } from '@example-app/shared/pipes'; -import { MaterialModule } from '@example-app/material'; - -export const COMPONENTS = [ - BookAuthorsComponent, - BookDetailComponent, - BookPreviewComponent, - BookPreviewListComponent, - BookSearchComponent, -]; - -@NgModule({ - imports: [ - CommonModule, - ReactiveFormsModule, - MaterialModule, - RouterModule, - PipesModule, - ], - declarations: COMPONENTS, - exports: COMPONENTS, -}) -export class ComponentsModule {} +export * from './book-authors.component'; +export * from './book-detail.component'; +export * from './book-preview.component'; +export * from './book-preview-list.component'; +export * from './book-search.component'; diff --git a/projects/example-app/src/app/books/containers/collection-page.component.spec.ts b/projects/example-app/src/app/books/containers/collection-page.component.spec.ts index f110737588..eaadeeb9e6 100644 --- a/projects/example-app/src/app/books/containers/collection-page.component.spec.ts +++ b/projects/example-app/src/app/books/containers/collection-page.component.spec.ts @@ -1,17 +1,21 @@ -import { CollectionPageComponent } from '@example-app/books/containers/collection-page.component'; -import { Store } from '@ngrx/store'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; + import { MatCardModule, MatInputModule } from '@angular/material'; -import { BookPreviewListComponent } from '@example-app/books/components/book-preview-list.component'; -import { BookPreviewComponent } from '@example-app/books/components/book-preview.component'; +import { Store } from '@ngrx/store'; +import { MockStore, provideMockStore } from '@ngrx/store/testing'; + import { CollectionPageActions } from '@example-app/books/actions'; +import { + BookAuthorsComponent, + BookPreviewComponent, + BookPreviewListComponent, +} from '@example-app/books/components'; +import { CollectionPageComponent } from '@example-app/books/containers'; import * as fromBooks from '@example-app/books/reducers'; -import { EllipsisPipe } from '@example-app/shared/pipes/ellipsis.pipe'; import { AddCommasPipe } from '@example-app/shared/pipes/add-commas.pipe'; -import { BookAuthorsComponent } from '@example-app/books/components/book-authors.component'; -import { provideMockStore, MockStore } from '@ngrx/store/testing'; +import { EllipsisPipe } from '@example-app/shared/pipes/ellipsis.pipe'; describe('Collection Page', () => { let fixture: ComponentFixture; diff --git a/projects/example-app/src/app/books/containers/collection-page.component.ts b/projects/example-app/src/app/books/containers/collection-page.component.ts index f0ebfd39e7..0792a5c910 100644 --- a/projects/example-app/src/app/books/containers/collection-page.component.ts +++ b/projects/example-app/src/app/books/containers/collection-page.component.ts @@ -1,9 +1,10 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; + import { select, Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { CollectionPageActions } from '@example-app/books/actions'; -import { Book } from '@example-app/books/models/book'; +import { Book } from '@example-app/books/models'; import * as fromBooks from '@example-app/books/reducers'; @Component({ diff --git a/projects/example-app/src/app/books/containers/find-book-page.component.spec.ts b/projects/example-app/src/app/books/containers/find-book-page.component.spec.ts index 6590e48330..e6b8802e00 100644 --- a/projects/example-app/src/app/books/containers/find-book-page.component.spec.ts +++ b/projects/example-app/src/app/books/containers/find-book-page.component.spec.ts @@ -1,24 +1,27 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { RouterTestingModule } from '@angular/router/testing'; + import { MatCardModule, MatInputModule, MatProgressSpinnerModule, } from '@angular/material'; import { Store } from '@ngrx/store'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { MockStore, provideMockStore } from '@ngrx/store/testing'; -import { BookSearchComponent } from '@example-app/books/components/book-search.component'; -import { BookPreviewComponent } from '@example-app/books/components/book-preview.component'; -import { BookPreviewListComponent } from '@example-app/books/components/book-preview-list.component'; -import { RouterTestingModule } from '@angular/router/testing'; -import { EllipsisPipe } from '@example-app/shared/pipes/ellipsis.pipe'; -import { BookAuthorsComponent } from '@example-app/books/components/book-authors.component'; -import { AddCommasPipe } from '@example-app/shared/pipes/add-commas.pipe'; -import { FindBookPageComponent } from '@example-app/books/containers/find-book-page.component'; import { FindBookPageActions } from '@example-app/books/actions'; +import { + BookAuthorsComponent, + BookPreviewComponent, + BookPreviewListComponent, + BookSearchComponent, +} from '@example-app/books/components'; +import { FindBookPageComponent } from '@example-app/books/containers'; import * as fromBooks from '@example-app/books/reducers'; -import { provideMockStore, MockStore } from '@ngrx/store/testing'; +import { AddCommasPipe } from '@example-app/shared/pipes/add-commas.pipe'; +import { EllipsisPipe } from '@example-app/shared/pipes/ellipsis.pipe'; describe('Find Book Page', () => { let fixture: ComponentFixture; diff --git a/projects/example-app/src/app/books/containers/find-book-page.component.ts b/projects/example-app/src/app/books/containers/find-book-page.component.ts index 3e260678ed..d467559913 100644 --- a/projects/example-app/src/app/books/containers/find-book-page.component.ts +++ b/projects/example-app/src/app/books/containers/find-book-page.component.ts @@ -1,10 +1,11 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; + import { select, Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { take } from 'rxjs/operators'; import { FindBookPageActions } from '@example-app/books/actions'; -import { Book } from '@example-app/books/models/book'; +import { Book } from '@example-app/books/models'; import * as fromBooks from '@example-app/books/reducers'; @Component({ diff --git a/projects/example-app/src/app/books/containers/index.ts b/projects/example-app/src/app/books/containers/index.ts new file mode 100644 index 0000000000..8e8ee5ff6b --- /dev/null +++ b/projects/example-app/src/app/books/containers/index.ts @@ -0,0 +1,4 @@ +export * from './collection-page.component'; +export * from './find-book-page.component'; +export * from './selected-book-page.component'; +export * from './view-book-page.component'; diff --git a/projects/example-app/src/app/books/containers/selected-book-page.component.spec.ts b/projects/example-app/src/app/books/containers/selected-book-page.component.spec.ts index 24dd13a227..4de859d8a8 100644 --- a/projects/example-app/src/app/books/containers/selected-book-page.component.spec.ts +++ b/projects/example-app/src/app/books/containers/selected-book-page.component.spec.ts @@ -1,16 +1,19 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { SelectedBookPageComponent } from '@example-app/books/containers/selected-book-page.component'; -import { Store } from '@ngrx/store'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; + import { MatCardModule } from '@angular/material'; +import { Store } from '@ngrx/store'; +import { MockStore, provideMockStore } from '@ngrx/store/testing'; import { SelectedBookPageActions } from '@example-app/books/actions'; +import { + BookAuthorsComponent, + BookDetailComponent, +} from '@example-app/books/components'; +import { SelectedBookPageComponent } from '@example-app/books/containers'; +import { Book, generateMockBook } from '@example-app/books/models'; import * as fromBooks from '@example-app/books/reducers'; -import { BookDetailComponent } from '@example-app/books/components/book-detail.component'; -import { Book, generateMockBook } from '@example-app/books/models/book'; -import { BookAuthorsComponent } from '@example-app/books/components/book-authors.component'; import { AddCommasPipe } from '@example-app/shared/pipes/add-commas.pipe'; -import { provideMockStore, MockStore } from '@ngrx/store/testing'; describe('Selected Book Page', () => { let fixture: ComponentFixture; diff --git a/projects/example-app/src/app/books/containers/selected-book-page.component.ts b/projects/example-app/src/app/books/containers/selected-book-page.component.ts index 727f5e4d73..99e2c64563 100644 --- a/projects/example-app/src/app/books/containers/selected-book-page.component.ts +++ b/projects/example-app/src/app/books/containers/selected-book-page.component.ts @@ -1,10 +1,11 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; -import { Store, select } from '@ngrx/store'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; + +import { select, Store } from '@ngrx/store'; import { Observable } from 'rxjs'; -import * as fromBooks from '@example-app/books/reducers'; import { SelectedBookPageActions } from '@example-app/books/actions'; -import { Book } from '@example-app/books/models/book'; +import { Book } from '@example-app/books/models'; +import * as fromBooks from '@example-app/books/reducers'; @Component({ selector: 'bc-selected-book-page', diff --git a/projects/example-app/src/app/books/containers/view-book-page.component.spec.ts b/projects/example-app/src/app/books/containers/view-book-page.component.spec.ts index 4fea62f70e..ee62b78e03 100644 --- a/projects/example-app/src/app/books/containers/view-book-page.component.spec.ts +++ b/projects/example-app/src/app/books/containers/view-book-page.component.spec.ts @@ -1,17 +1,20 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { Store } from '@ngrx/store'; import { ActivatedRoute } from '@angular/router'; + +import { Store } from '@ngrx/store'; +import { provideMockStore, MockStore } from '@ngrx/store/testing'; import { BehaviorSubject } from 'rxjs'; import { MatCardModule } from '@angular/material'; -import { ViewBookPageComponent } from '@example-app/books/containers/view-book-page.component'; +import { + BookAuthorsComponent, + BookDetailComponent, +} from '@example-app/books/components'; +import { SelectedBookPageComponent } from '@example-app/books/containers'; +import { ViewBookPageComponent } from '@example-app/books/containers'; import { ViewBookPageActions } from '@example-app/books/actions'; import * as fromBooks from '@example-app/books/reducers'; -import { SelectedBookPageComponent } from '@example-app/books/containers/selected-book-page.component'; -import { BookDetailComponent } from '@example-app/books/components/book-detail.component'; -import { BookAuthorsComponent } from '@example-app/books/components/book-authors.component'; import { AddCommasPipe } from '@example-app/shared/pipes/add-commas.pipe'; -import { provideMockStore, MockStore } from '@ngrx/store/testing'; describe('View Book Page', () => { let fixture: ComponentFixture; diff --git a/projects/example-app/src/app/books/effects/book.effects.spec.ts b/projects/example-app/src/app/books/effects/book.effects.spec.ts index 3e9c261389..2b235dac5e 100644 --- a/projects/example-app/src/app/books/effects/book.effects.spec.ts +++ b/projects/example-app/src/app/books/effects/book.effects.spec.ts @@ -1,16 +1,17 @@ import { TestBed } from '@angular/core/testing'; + import { Actions } from '@ngrx/effects'; import { provideMockActions } from '@ngrx/effects/testing'; import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { Observable } from 'rxjs'; -import { GoogleBooksService } from '@example-app/core/services/google-books.service'; import { BooksApiActions, FindBookPageActions, } from '@example-app/books/actions'; -import { Book } from '@example-app/books/models/book'; -import { BookEffects } from '@example-app/books/effects/book.effects'; +import { BookEffects } from '@example-app/books/effects'; +import { Book } from '@example-app/books/models'; +import { GoogleBooksService } from '@example-app/core/services/google-books.service'; describe('BookEffects', () => { let effects: BookEffects; diff --git a/projects/example-app/src/app/books/effects/book.effects.ts b/projects/example-app/src/app/books/effects/book.effects.ts index 53c6d460aa..4f55f9faca 100644 --- a/projects/example-app/src/app/books/effects/book.effects.ts +++ b/projects/example-app/src/app/books/effects/book.effects.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; + +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { asyncScheduler, EMPTY as empty, of } from 'rxjs'; import { catchError, @@ -10,12 +11,12 @@ import { takeUntil, } from 'rxjs/operators'; -import { GoogleBooksService } from '@example-app/core/services/google-books.service'; +import { Book } from '@example-app/books/models'; import { BooksApiActions, FindBookPageActions, } from '@example-app/books/actions'; -import { Book } from '@example-app/books/models/book'; +import { GoogleBooksService } from '@example-app/core/services/google-books.service'; /** * Effects offer a way to isolate and easily test side-effects within your diff --git a/projects/example-app/src/app/books/effects/collection.effects.spec.ts b/projects/example-app/src/app/books/effects/collection.effects.spec.ts index 4c21c99c49..2b5f0cf34e 100644 --- a/projects/example-app/src/app/books/effects/collection.effects.spec.ts +++ b/projects/example-app/src/app/books/effects/collection.effects.spec.ts @@ -1,20 +1,20 @@ import { TestBed } from '@angular/core/testing'; -import { Actions } from '@ngrx/effects'; -import { provideMockActions } from '@ngrx/effects/testing'; -import { cold, hot } from 'jasmine-marbles'; -import { Observable } from 'rxjs'; import { CollectionApiActions, - SelectedBookPageActions, CollectionPageActions, + SelectedBookPageActions, } from '@example-app/books/actions'; -import { Book } from '@example-app/books/models/book'; -import { CollectionEffects } from '@example-app/books/effects/collection.effects'; +import { CollectionEffects } from '@example-app/books/effects'; +import { Book } from '@example-app/books/models'; import { BookStorageService, LOCAL_STORAGE_TOKEN, -} from '@example-app/core/services/'; +} from '@example-app/core/services'; +import { Actions } from '@ngrx/effects'; +import { provideMockActions } from '@ngrx/effects/testing'; +import { cold, hot } from 'jasmine-marbles'; +import { Observable } from 'rxjs'; describe('CollectionEffects', () => { let db: any; diff --git a/projects/example-app/src/app/books/effects/collection.effects.ts b/projects/example-app/src/app/books/effects/collection.effects.ts index 942e32c97f..b4e106ba86 100644 --- a/projects/example-app/src/app/books/effects/collection.effects.ts +++ b/projects/example-app/src/app/books/effects/collection.effects.ts @@ -1,14 +1,17 @@ import { Injectable } from '@angular/core'; -import { Actions, Effect, ofType, createEffect } from '@ngrx/effects'; + +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { defer, of } from 'rxjs'; import { catchError, map, mergeMap, switchMap } from 'rxjs/operators'; -import { Book } from '@example-app/books/models/book'; + import { CollectionApiActions, CollectionPageActions, SelectedBookPageActions, } from '@example-app/books/actions'; +import { Book } from '@example-app/books/models'; import { BookStorageService } from '@example-app/core/services'; + @Injectable() export class CollectionEffects { /** diff --git a/projects/example-app/src/app/books/effects/index.ts b/projects/example-app/src/app/books/effects/index.ts new file mode 100644 index 0000000000..a80391d48d --- /dev/null +++ b/projects/example-app/src/app/books/effects/index.ts @@ -0,0 +1,2 @@ +export * from './book.effects'; +export * from './collection.effects'; diff --git a/projects/example-app/src/app/books/guards/index.ts b/projects/example-app/src/app/books/guards/index.ts new file mode 100644 index 0000000000..87fade4c20 --- /dev/null +++ b/projects/example-app/src/app/books/guards/index.ts @@ -0,0 +1 @@ +export * from './book-exists.guard'; diff --git a/projects/example-app/src/app/books/index.ts b/projects/example-app/src/app/books/index.ts new file mode 100644 index 0000000000..cd945ef778 --- /dev/null +++ b/projects/example-app/src/app/books/index.ts @@ -0,0 +1 @@ +export * from './books.module'; diff --git a/projects/example-app/src/app/books/models/index.ts b/projects/example-app/src/app/books/models/index.ts new file mode 100644 index 0000000000..ee47330e0e --- /dev/null +++ b/projects/example-app/src/app/books/models/index.ts @@ -0,0 +1 @@ +export * from './book'; diff --git a/projects/example-app/src/app/books/reducers/books.reducer.spec.ts b/projects/example-app/src/app/books/reducers/books.reducer.spec.ts index fc6429e840..1be327a452 100644 --- a/projects/example-app/src/app/books/reducers/books.reducer.spec.ts +++ b/projects/example-app/src/app/books/reducers/books.reducer.spec.ts @@ -6,7 +6,7 @@ import { ViewBookPageActions, CollectionApiActions, } from '@example-app/books/actions'; -import { Book, generateMockBook } from '@example-app/books/models/book'; +import { Book, generateMockBook } from '@example-app/books/models'; describe('BooksReducer', () => { const book1 = generateMockBook(); diff --git a/projects/example-app/src/app/books/reducers/books.reducer.ts b/projects/example-app/src/app/books/reducers/books.reducer.ts index 049d4902c2..388e7349a3 100644 --- a/projects/example-app/src/app/books/reducers/books.reducer.ts +++ b/projects/example-app/src/app/books/reducers/books.reducer.ts @@ -1,12 +1,13 @@ import { createEntityAdapter, EntityAdapter, EntityState } from '@ngrx/entity'; -import { Book } from '@example-app/books/models/book'; +import { createReducer, on } from '@ngrx/store'; + import { - BooksApiActions, BookActions, - ViewBookPageActions, + BooksApiActions, CollectionApiActions, + ViewBookPageActions, } from '@example-app/books/actions'; -import { createReducer, on } from '@ngrx/store'; +import { Book } from '@example-app/books/models'; /** * @ngrx/entity provides a predefined interface for handling diff --git a/projects/example-app/src/app/books/reducers/collection.reducer.ts b/projects/example-app/src/app/books/reducers/collection.reducer.ts index 9a0145c760..27ff2748f5 100644 --- a/projects/example-app/src/app/books/reducers/collection.reducer.ts +++ b/projects/example-app/src/app/books/reducers/collection.reducer.ts @@ -1,9 +1,9 @@ +import { createReducer, on } from '@ngrx/store'; + import { - SelectedBookPageActions, - CollectionPageActions, CollectionApiActions, + CollectionPageActions, } from '@example-app/books/actions'; -import { createReducer, on } from '@ngrx/store'; export interface State { loaded: boolean; diff --git a/projects/example-app/src/app/books/reducers/index.ts b/projects/example-app/src/app/books/reducers/index.ts index 38f7a0dbd2..2487269383 100644 --- a/projects/example-app/src/app/books/reducers/index.ts +++ b/projects/example-app/src/app/books/reducers/index.ts @@ -1,3 +1,4 @@ +import { Book } from '@example-app/books/models'; import { createSelector, createFeatureSelector, @@ -8,7 +9,6 @@ import * as fromSearch from '@example-app/books/reducers/search.reducer'; import * as fromBooks from '@example-app/books/reducers/books.reducer'; import * as fromCollection from '@example-app/books/reducers/collection.reducer'; import * as fromRoot from '@example-app/reducers'; -import { Book } from '../models/book'; export interface BooksState { search: fromSearch.State; diff --git a/projects/example-app/src/app/core/services/book-storage.service.spec.ts b/projects/example-app/src/app/core/services/book-storage.service.spec.ts index ddf6681292..00e5949ae4 100644 --- a/projects/example-app/src/app/core/services/book-storage.service.spec.ts +++ b/projects/example-app/src/app/core/services/book-storage.service.spec.ts @@ -1,6 +1,8 @@ import { TestBed } from '@angular/core/testing'; + import { cold } from 'jasmine-marbles'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; import { BookStorageService, LOCAL_STORAGE_TOKEN, diff --git a/projects/example-app/src/app/core/services/book-storage.service.ts b/projects/example-app/src/app/core/services/book-storage.service.ts index 53c886d6c3..4b74a0f7c1 100644 --- a/projects/example-app/src/app/core/services/book-storage.service.ts +++ b/projects/example-app/src/app/core/services/book-storage.service.ts @@ -1,12 +1,9 @@ -import { - Injectable, - InjectionToken, - FactoryProvider, - Inject, -} from '@angular/core'; +import { Inject, Injectable, InjectionToken } from '@angular/core'; + import { Observable, of, throwError } from 'rxjs'; import { map, tap } from 'rxjs/operators'; -import { Book } from '@example-app/books/models/book'; + +import { Book } from '@example-app/books/models'; export function storageFactory() { return typeof window === undefined || typeof localStorage === undefined diff --git a/projects/example-app/src/app/core/services/google-books.service.ts b/projects/example-app/src/app/core/services/google-books.service.ts index 5643744ee8..84d8b570b2 100644 --- a/projects/example-app/src/app/core/services/google-books.service.ts +++ b/projects/example-app/src/app/core/services/google-books.service.ts @@ -1,9 +1,10 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; + import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { Book } from '@example-app/books/models/book'; +import { Book } from '@example-app/books/models'; @Injectable({ providedIn: 'root',