万本电子书0元读

万本电子书0元读

顶部广告

Architecting Angular Applications with Redux, RxJS, and NgRx电子书

售       价:¥

8人正在读 | 0人评论 9.8

作       者:Christoffer Noring

出  版  社:Packt Publishing

出版时间:2018-03-26

字       数:41.4万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Manage state in Angular to write high performing web apps by combining the power of Flux, RxJS, and NgRx About This Book ? Learn what makes an excellent Angular application architecture ? Use Redux to write performant, consistent Angular applications ? Incorporate Reactive Programming principles and RxJS to make it easier to develop, test, and debug your Angular applications Who This Book Is For If you have been developing Angular applications and want to dive deeper into the Angular architecture with Redux, RxJS, and NgRx to write robust web apps, then this book is for you. What You Will Learn ? Understand the one-way data flow and Flux pattern ? Work with functional programming and asynchronous data streams ? Figure out how RxJS can help us address the flaws in promises ? Set up different versions of cascading calls ? Explore advanced operators ? Get familiar with the Redux pattern and its principles ? Test and debug different features of your application ? Build your own lightweight app using Flux, Redux, and NgRx In Detail Managing the state of large-scale web applications is a highly challenging task with the need to align different components, backends, and web workers harmoniously. When it comes to Angular, you can use NgRx, which combines the simplicity of Redux with the reactive programming power of RxJS to build your application architecture, making your code elegant and easy to reason about, debug, and test. In this book, we start by looking at the different ways of architecting Angular applications and some of the patterns that are involved in it. This will be followed by a discussion on one-way data flow, the Flux pattern, and the origin of Redux. The book introduces you to declarative programming or, more precisely, functional programming and talks about its advantages. We then move on to the reactive programming paradigm. Reactive programming is a concept heavily used in Angular and is at the core of NgRx. Later, we look at RxJS, as a library and master it. We thoroughly describe how Redux works and how to implement it from scratch. The two last chapters of the book cover everything NgRx has to offer in terms of core functionality and supporting libraries, including how to build a micro implementation of NgRx. This book will empower you to not only use Redux and NgRx to the fullest, but also feel confident in building your own version, should you need it. Style and approach This book covers everything there is to know to get well-acquainted with Angular without bogging you down. Everything is neatly laid out under clear headings for quick consultation, giving you the information required to understand a concept immediately.
目录展开

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

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部