Skip to content

Commit

Permalink
refactor(example): use barrel import for book module (#1850)
Browse files Browse the repository at this point in the history
Closes #1684
  • Loading branch information
jasonhodges authored and brandonroberts committed May 14, 2019
1 parent 070228c commit 92a6b20
Show file tree
Hide file tree
Showing 34 changed files with 166 additions and 136 deletions.
3 changes: 2 additions & 1 deletion projects/example-app/src/app/books/actions/book.actions.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 8 additions & 5 deletions projects/example-app/src/app/books/books-routing.module.ts
Original file line number Diff line number Diff line change
@@ -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 },
Expand Down
54 changes: 36 additions & 18 deletions projects/example-app/src/app/books/books.module.ts
Original file line number Diff line number Diff line change
@@ -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,

/**
Expand All @@ -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 {}
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
39 changes: 5 additions & 34 deletions projects/example-app/src/app/books/components/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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<CollectionPageComponent>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
Original file line number Diff line number Diff line change
@@ -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<FindBookPageComponent>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
4 changes: 4 additions & 0 deletions projects/example-app/src/app/books/containers/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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<SelectedBookPageComponent>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ViewBookPageComponent>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit 92a6b20

Please sign in to comment.