Architecting Angular Applications with Redux,RxJS,and NgRx
Christoffer Noring更新时间:2021-08-27 19:56:57
最新章节:Leave a review - let other readers know what you think封面
Title Page
Copyright and Credits
Architecting Angular Applications with Redux RxJS and NgRx
Packt Upsell
Why subscribe?
PacktPub.com
Foreword
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Quick Look Back at Data Services for Simple Apps
Model-View-Controller – the pattern we all know
Cohesion and coupling – establishing a common language
Explaining the components of MVC
The model
The view
The controller
Interactions – the behavior between the components
MVC summary
An MVC flow in Angular
The model
The component – a controller and a building block
First responder to a route
Used as a building block
Components from an architectural standpoint
NgModule – our new facade (and some other bits)
Using ES2015 modules
Consuming a module
An Angular example
Multiple exports
The default import/export
Renaming imports
The service
Service without dependencies
Service with dependencies
Dependency Injection
Dependency Injection in Angular using providers
Overriding an existing construct
Overriding at runtime
Overriding constants
Resolving your dependencies with @Injectable
Fetching and persisting data with HTTP – introducing services with Observables
Fetching data with the HTTP service
Summary
1.21 Gigawatt – Flux Pattern Explained
Core concepts overview
A uniform data flow
Action – capture the intent
Dispatcher – the spider in the web
Listening to the dispatcher
The store – managing state data retrieval and callbacks
The view
Demoing a uniform data flow
Creating a selection view
Adding the dispatcher
Adding the store
Adding a selected view
Running the demo
Adding more actions to our flow
Cleaning up the view
Cleaning up the store
Adding EventEmitter
Adding to and cleaning up the register method
Further improvements
Adding immutability
Summarizing
Adding AJAX calls
An even bigger solution
Summary
Asynchronous Programming
The callback pattern
The callback pattern on the web
The callback pattern in Node.js
Problems with structuring async code – callback hell
Promises
Thenables
Handling rejected promises
Chaining – dealing with several promises
Asynchronous libraries
Async library
async.map()
async.parallel()
async.series()
Async/await
Summary
Functional Reactive Programming
Functional programming versus imperative programming
Imperative programming versus declarative programming
First-class higher-order functions
Pure functions
Recursion
No more loops
Reoccurring pattern
Summarise
Count
Width
Asynchronous data streams
Comparing lists to async streams – preparing for RxJS
Combining the functional programming paradigm with streams
Projection
Filtering
Combining mindsets
Summary
RxJS Basics
Observer pattern
RxJS core concepts
Observable and Observer
Producer
Observable error and completion
Operator
Creating Observables
Creation operators
of()
interval()
from()
fromEvent()
bindCallback()
Cleanup
Subscriptions
Creating a core implementation of RxJS
Implementing create()
Handling subscriptions
Adding operators
Revisiting the basics adding errors and complete
Summary
Manipulating Streams and Their Values
Starting out
Understanding operators
Stream in a stream
AJAX
fetch()
ajax() operator
Cascading calls
A deeper look
Creation operators
of() operator
from() operator
range() operator
fromEvent() operator
Combination
merge() operator
combineLatest()
zip()
concat()
Mathematical
max
min
sum
Time
interval() operator
timer() operator
delay() operator
sampleTime() operator
debounceTime() operator
Grouping
buffer() operator
bufferTime() operator
Thinking in streams
Summary
RxJS Advanced
Hot cold and warm Observables
Making a stream hot
Warm streams
Subjects
Using Subject for cascading lists
BehaviorSubject
ReplaySubject
AsyncSubject
Error handling
Catch and continue
Ignoring the error
Retry
Advanced Retry
Marble testing
Set up
Writing your first marble test
Fleshing out with more tests
Pipeable operators
Creating reusable operators with let()
Shifting to pipeable operators
Summary
Redux
Principles
Single source of truth
Read-only states
Changing states with pure functions
Core concepts
Immutability patterns
Changing a list
Changing an object
Using reducers
Merging all reducers together
Data flow
Creating the action
Creating a controller class – create-view.js
Creating a store implementation
Testing out our store
Cleaning up the implementation
Creating our second controller class – list-view.js
Adding subscription capability to our store
Creating a program
Setting up our environment
Creating the missing files and running our program
Dealing with asynchronous calls
Creating a demo with Redux and asynchronous
Best practices
Summary
NgRx – Reduxing that Angular App
NgRx overview
A word on state management
@ngrx/store – state management
A more complex example – a list
Best practices
A cleanup example
Create a dedicated directory and feature module
Add reducer and constants
Moving the component to our jedi directory
Registering our reducer with the store
Leveraging types and feature modules
Going from forRoot() to forFeature()
Setting up forFeature() from string to selection function
Introducing NgRx types for setting up the state
Giving forFeature() a type
Several states in the same feature module
Adding the counter-list reducer
Adding the component
Adding the constants
Adding the action methods
Adding the model
Register our reducers
Component architecture
@ngrx/store-devtools – debugging
@ngrx/effects – working with side effects
Installing and setting it up
Creating our first effect – a realistic scenario
Creating our constants
Action creators
Reducer with a new type of default state
The effect – listening to a specific dispatched action
Adding a component – introducing selectors
Extending our example with the create effect
Updating the constants file
Updating the reducer
Additional actions
Adding another effect
Supporting the effect in our component
Running a demo of the app
Summary
NgRx – In Depth
@ngrx/entity
Setting it up
Selecting our data
Adding the full CRUD
Creating users
Updating users
Deleting users
@ngrx/router-store
Installation and set up
Investigating the router state
Custom serialization
Navigating through dispatch
Understanding NgRx – building our own micro implementation
Adding a store
Merging the states in a better way
Implementing a reducer and integrating it with the store
Dealing with slices of state
Handling side effects
@ngrx/schematics
Setting it up
Generating constructs
Generating actions
Generating a container
Generating an effect
Generating an entity
Generating a feature
Generating a reducer
Generating a store
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
更新时间:2021-08-27 19:56:57