万本电子书0元读

万本电子书0元读

顶部广告

Flux Architecture电子书

售       价:¥

0人正在读 | 0人评论 9.8

作       者:Adam Boduch

出  版  社:Packt Publishing

出版时间:2016-05-24

字       数:181.6万

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

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

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Learn to build powerful and scalable applications with Flux, the architecture that serves billions of Facebook users every dayAbout This Book·This the first resource dedicated to the new architectural pattern that powers Facebook·You'll learn all the tips and tricks you need to get the most out of Flux·Filled with practical, hands-on samples, you'll not only understand how Flux works, but will be able to start building Flux-powered applications straight away·Written by Adam Boduch, software architect at Virtustream (EMC), and author of JavaScript at Scale, JavaScript Concurrency, and jQuery UI Cookbook for Packt PublishingWho This Book Is ForAre you trying to use React, but are struggling to get your head around Flux? Maybe you're tired of MV* spaghetti code at scale? Do you find yourself asking what the Flux?!Flux Architecture will guide you through everything you need to understand the Flux pattern, and design and build powerful web applications that rely on the Flux architecture.You don't need to know what Flux is or how it works to read along with the book. No knowledge of Flux's partner technology, ReactJS, is necessary to follow along, but it is recommended that you have a good working knowledge of JavaScript.What You Will Learn·Understand the Flux pattern and how it will impact your React applications·Build real-world applications that rely on Flux·Handle asynchronous actions in your application·Implement immutable stores with Immutable.js·Replace React.js with alternate View components such as jQuery and Handlebars·Test and benchmark your Flux architecture using Jest—Facebook's enhancement of the Jasmine libraryIn DetailWhilst React has become Facebook's poster-child for clean, complex, and modern web development, it has quietly been underpinned by its simplicity. It's just a view. The real beauty in React is actually the architectural pattern that handles data in and out of React applications: Flux. With Flux, you're able to build data-rich applications that engage your users, and scale to meet every demand. It is a key part of the Facebook technology stack that serves billions of users every day.This book will start by introducing the Flux pattern and help you get an understanding of what it is and how it works. After this, we'll build real-world React applications that highlight the power and simplicity of Flux in action. Finally, we look at the landscape of Flux and explore the Alt and Redux libraries that make React and Flux developments easier.Filled with fully-worked examples and code-first explanations, by the end of the book, you'll not only have a rock solid understanding of the architecture, but will be ready to implement Flux architecture in anger.Style and approachThis book is filled with practical, hands-on examples. You'll not only understand how Flux works, but will be able to start building Flux-powered applications straight away.
目录展开

Flux Architecture

Flux Architecture

Credits

About the Author

About the Reviewer

www.PacktPub.com

eBooks, discount offers, and more

Why subscribe?

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Errata

Piracy

Questions

1. What is Flux?

Flux is a set of patterns

Data entry points

Managing state

Keeping updates synchronous

Information architecture

Flux isn't another framework

Flux solves conceptual problems

Data flow direction

Predictable root cause

Consistent notifications

Simple architectural layers

Loosely coupled rendering

Flux components

Action

Dispatcher

Store

View

Installing the Flux package

Summary

2. Principles of Flux

Challenges with MV*

Separation of concerns

Cascading updates

Model update responsibilities

Unidirectional data

From start to finish

No side-effects

Explicit over implicit

Updates via hidden side-effects

Data changes state in one place

Too many actions?

Layers over hierarchies

Multiple component hierarchies

Hierarchy depth and side-effects

Data-flow and layers

Application data and UI state

Two of the same thing

Tightly coupled transformations

Feature centric

Summary

3. Building a Skeleton Architecture

General organization

Directory structure

Dependency management

Information design

Users don't understand models

Stores map to what the user sees

What do we have to work with?

Putting stores into action

Fetching API data

Changing API resource state

Local actions

Stores and feature domains

Identifying top-level features

Irrelevant API data

Structuring store data

Bare bone views

Finding missing data

Identifying actions

End-to-end scenarios

Action checklist

Store checklist

View checklist

Summary

4. Creating Actions

Action names and constants

Action name conventions

Static action data

Organizing action constants

Feature action creators

When modularity is needed

Modular architecture

Mocking data

Mocking existing APIs

Mocking new APIs

Replacing action creators

Stateful action creators

Integrating with other systems

Web socket connectivity

Parameterized action creators

Removing redundant actions

Keeping actions generic

Creating action partials

Summary

5. Asynchronous Actions

Keeping Flux synchronous

Why synchronicity?

Encapsulating asynchronous behavior

Asynchronous action semantics

Making API calls

APIs are the common case

API calls and user interactivity

Combining API calls

Complex action creators

Composing action creators

Returning promises

Synchronizing without promises

Composing asynchronous behavior

Handling errors

Summary

6. Changing Flux Store State

Adapting to changing information

Changing API data

Changing feature functionality

Impacted components

Reducing duplicate store data

Generic store data

Registering generic stores

Combining generic and specific data

Handling store dependencies

Waiting for stores

Data dependencies

UI dependencies

View update order

Store registration order

Prioritizing view rendering

Dealing with store complexity

Too many stores

Rethinking feature domains

Summary

7. Viewing Information

Passing views data

Data via the change event

Views decide when to render

Keeping views stateless

UI state belongs in stores

No querying the DOM

View responsibilities

Rendering store data

Subview structure

User interactivity

Using ReactJS with Flux

Setting the view state

Composing views

Reacting to events

Routing and actions

Summary

8. Information Lifecycle

Component life cycle difficulties

Reclaiming unused resources

Hidden dependencies

Memory leaks

Flux structures are static

Singleton pattern

Comparison to models

Static views

Scaling information

What scales well?

Minimal information required

Actions that scale

Inactive stores

Deleting store data

Optimizing inactive stores

Keeping store data

Summary

9. Immutable Stores

Renouncing hidden updates

How to break Flux

Getting store data

Everything is immutable

Enforcing unidirectional data flow

Backwards, sideways, and leaky data flow

Too many stores?

Not enough actions

Enforcing immutability

The cost of immutable data

Garbage collection is expensive

Batched mutations

Offsetting the cost

Using Immutable.js

Immutable lists and maps

Immutable transformations

Change detection

Summary

10. Implementing a Dispatcher

Abstract dispatcher interface

Store registration

Dispatching payloads

Handling dependencies

Challenges with the dispatcher

Educational purposes

Singleton dispatchers

Manual store registration

Error-prone dependency management

Building a dispatcher module

Encapsulating store references

Handling dependencies

Dispatching actions

Improving store registration

Base store class

An action method

Summary

11. Alternative View Components

ReactJS is a good fit for Flux

ReactJS is unidirectional

Re-rendering new data is easy

Small code footprint

The downsides of ReactJS

Virtual DOM and memory

JSX and markup

Vendor lock-in

Using jQuery and Handlebars

Why jQuery and Handlebars?

Rendering templates

Composing views

Handling events

Using VanillaJS

Keeping my options open

Moving to React

New hotness

Summary

12. Leveraging Flux Libraries

Implementing core Flux components

Customizing the dispatcher

Implementing a base store

Creating actions

Implementation pain points

Dispatching asynchronous actions

Partitioning stores

Using Alt

The core ideas

Creating stores

Declaring action creators

Listening for state changes

Rendering views and dispatching actions

Using Redux

The core ideas

Reducers and stores

Redux actions

Rendering components and dispatching actions

Summary

13. Testing and Performance

Hello Jest

Testing action creators

Synchronous functions

Asynchronous functions

Testing stores

Testing store listeners

Testing initial conditions

Performance goals

User perceived performance

Measured performance

Performance requirements

Profiling tools

Asynchronous actions

Store memory

CPU utilization

Benchmarking tools

Benchmarking code

State transformations

Summary

14. Flux and the Software Development Lifecycle

Flux is open to interpretation

Implementation option 1 – just the patterns

Implementation option 2 – use a Flux library

Roll your own Flux

Development methodologies

Upfront Flux activities

Maturing a Flux application

Borrowing ideas from Flux

Unidirectional data flow

Information design is king

Packaging Flux components

The case for monolithic Flux

Packages enable scale

Installable Flux components

Summary

Index

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

发表评论

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

买过这本书的人还买过

读了这本书的人还在读

回顶部