side effects in you Angular application. It works by deriving a stream of updates for your application’s components called the “action stream”. • You apply a pure function called a “reducer” to the action stream as a means of deriving state in a deterministic way. • Long running processes called “effects” use RxJS operators to trigger side effects based on these updates and can optionally yield new changes back to the actions stream.
challenge branch 3. Familiarize yourself with the file structure 4. Where is movies state handled? 5. Where are the movies actions located? 6. How does the movies state flow into the movies component? 7. How are events in the movies component going to the movies reducer? Challenge github.com/CodeSequence/ngconf2019-ngrx-workshop Branch: challenge
has activeBookId and books properties 3. Define an initialState object that implements the BooksState interface 4. Create a reducer that defaults to initialState with a default case in a switch statement that returns state Challenge, pt 1 PR: 00-setup github.com/CodeSequence/ngconf2019-ngrx-workshop
and the books reducer to the reducers object 2. Open books-page.component.ts and inject the Store service into the constructor 3. Add an observable property to the component that gets all of the books from state using the select operator 4. Update books-page.component.html to use the async pipe to get the list of books Challenge, pt 2 PR: 00-setup github.com/CodeSequence/ngconf2019-ngrx-workshop
“create”, “update”, and “delete” actions 2. Use the helper functions already in books.reducer.ts 3. Update books-page.component.ts to dispatch “select”, “clear select”, “create”, “update”, and “delete” actions from the component 4. Remove the BooksService from the component Challenge PR: 01-reducers github.com/CodeSequence/ngconf2019-ngrx-workshop
various action types 2. Create strongly typed actions that adhere to good action hygiene for selecting a book, clearing the selection, creating a book, updating a book, and deleting a book. 3. Export the actions as a union type 4. Update books-page.components.ts and books.reducer.ts to use the new actions Challenge PR: 02-actions github.com/CodeSequence/ngconf2019-ngrx-workshop
in the getBooks() method of books.component.ts 2. Update books.reducer.ts to use EntityState to define BooksState 3. Create an unsorted entity adapter for BooksState and use it to initialize initialState 4. Update the reducer to use the adapter methods 5. Add a case statement for the “Enter” action that adds all of the initialBooks to the state 6. Update the books$ selector in books-page.component.ts to use the ids and entities properties of the books state to get the list of books Challenge PR: 03-entity github.com/CodeSequence/ngconf2019-ngrx-workshop
selectors for selectAll and selectEntities 2. Write a selector in books.reducer.ts that gets activeBookId 3. Use createSelector to create a selectActiveBook selector using selectEntities and selectActiveBookId 4. Use createSelector to create a selectEarningsTotal selector to calculate the gross total earnings of all books using selectAll 5. Create global versions of selectAllBooks, selectActiveBook, and selectBookEarningsTotal in state/index.ts using createSelector 6. Update books-page.component.ts and its template to use the selectAllBooks, selectActiveBook, and selectEarningsTotal selectors Challenge PR: 04-selectors github.com/CodeSequence/ngconf2019-ngrx-workshop
04-selectors branch 3. Familiarize yourself with the file structure 4. Where is books state handled? 5. Where are the books actions located? 6. How does the books state flow into the movies component? 7. How are events in the books page component going to the books reducer? Challenge github.com/CodeSequence/ngconf2019-ngrx-workshop Branch: 04-selectors
with an action union type 2. Create a file at app/books/books-api.effects.ts and add an effect class to it with an effect called loadBooks$ that calls BooksService.all() and maps the result into a BooksLoaded action 3. Register the effect using EffectsModule.forFeature([]) in books.module.ts 4. Update the books reducer to handle the BooksLoaded action by replacing the Enter action handler Challenge PR: 05-effects github.com/CodeSequence/ngconf2019-ngrx-workshop
to books- api.actions.ts and update books.reducer.ts to handle these new actions 2. Open books-api.effects.ts and update the loadBooks$ effect to use the exhaustMap operator 3. Add an effect for creating a book using the BooksService.create() method and the concatMap operator 4. Add an effect for updating a book using the BooksService.update() method and the concatMap operator 5. Add an effect for deleting a book using the BooksService.delete() method and the mergeMap operator Challenge PR: 06-advanced-effects github.com/CodeSequence/ngconf2019-ngrx-workshop
props factory function 2. Use the ReturnType utility type to replace the action union 3. Update books-api.actions.ts to use the createAction helper and the props factory function 4. Use the ReturnType utility type to replace the action union 5. Update books-page.component.ts, books-api.effects.ts, and books.reducer.ts to use the new action format Challenge PR: 07-action-creators github.com/CodeSequence/ngconf2019-ngrx-workshop
the initial state when no state is provided using the toBe matcher 2. Write tests that verifies the books reducer correctly transitions state for loading all books, creating a book, and deleting a book using the toMatchSnapshot matcher 3. Write tests that verifies the behavior of the selectActiveBook and selectAll selectors Challenge PR: 08-reducer-testing github.com/CodeSequence/ngconf2019-ngrx-workshop
of the effects, and a mock bookService 2. Use the TestBed to setup providers for the effects, actions, and the book service 3. Verify the behavior of the createBook$ effect using mock actions and test observables Challenge PR: 09-effects-testing github.com/CodeSequence/ngconf2019-ngrx-workshop
“Reactive Testing Strategies with NgRx” by Brandon Roberts & Mike Ryan https://youtu.be/MTZprd9tI6c “Authentication with NgRx” by Brandon Roberts https://youtu.be/46IRQgNtCGw “You Might Not Need NgRx” by Mike Ryan https://youtu.be/omnwu_etHTY “Just Another Marble Monday” by Sam Brennan & Keith Stewart https://youtu.be/dwDtMs4mN48