Professional Documents
Culture Documents
PDF Flux Architecture 1 Edition Edition Boduch Ebook Full Chapter
PDF Flux Architecture 1 Edition Edition Boduch Ebook Full Chapter
Boduch
Visit to download the full and correct content document:
https://textbookfull.com/product/flux-architecture-1-edition-edition-boduch/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://textbookfull.com/product/flux-architecture-1st-edition-
adam-boduch/
https://textbookfull.com/product/mental-files-in-flux-1st-
edition-francois-recanati/
https://textbookfull.com/product/the-pedestrianisation-and-its-
relation-with-enhancing-walkability-in-urban-spaces-1st-edition-
ma-najmaldin-hussein-1-1-department-of-architecture/
https://textbookfull.com/product/gitops-and-kubernetes-
continuous-deployment-with-argo-cd-jenkins-x-and-flux-1st-
edition-billy-yuen/
Microprocessor 1 Prolegomena Calculation and Storage
Functions Models of Computation and Computer
Architecture 1st Edition Philippe Darche
https://textbookfull.com/product/microprocessor-1-prolegomena-
calculation-and-storage-functions-models-of-computation-and-
computer-architecture-1st-edition-philippe-darche/
https://textbookfull.com/product/the-origin-of-life-patterns-in-
the-natural-inclusion-of-space-in-flux-1st-edition-alan-rayner-
auth/
https://textbookfull.com/product/architecture-and-affect-
precarious-spaces-routledge-research-in-architecture-1st-edition-
lilian-chee/
https://textbookfull.com/product/biomimicry-in-architecture-
second-edition-edition-pawlyn/
https://textbookfull.com/product/discovering-architecture-1st-
edition-frank-jacobus/
Table of Contents
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
Flux Architecture
Flux Architecture
Copyright © 2016 Packt Publishing
Livery Place
35 Livery Street
ISBN 978-1-78646-581-8
www.packtpub.com
Credits
Author
Adam Boduch
Reviewer
Commissioning Editor
Edward Gordon
Acquisition Editor
Smeet Thakkar
Divij Kotian
Technical Editor
Gebin George
Copy Editor
Charlotte Carneiro
Project Coordinator
Nikhil Nair
Proofreader
Safis Editing
Indexer
Rekha Nair
Graphics
Jason Monteiro
Production Coordinator
Manu Joseph
Cover Work
Manu Joseph
About the Author
Adam Boduch has been involved with large-scale JavaScript
development for nearly 10 years. Before moving to the front end, he
worked on several large-scale cloud computing products using
Python and Linux. No stranger to complexity, Adam has practical
experience with real-world software systems and the scaling
challenges they pose.
Many thanks to Chuck, Mark, Eric, and Adam, who I have had the
privilege to work with and learn from. I'm grateful to my family,
friends, and the experiences I have been blessed to be a part of.
www.PacktPub.com
eBooks, discount offers, and
more
Did you know that Packt offers eBook versions of every book
published, with PDF and ePub files available? You can upgrade to
the eBook version at www.PacktPub.com and as a print book
customer, you are entitled to a discount on the eBook copy. Get in
touch with us at <customercare@packtpub.com> for more details.
https://www2.packtpub.com/books/subscription/packtlib
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
For Melissa, thanks for all the love and support.
When I first started with Flux, I couldn't really see how such an
architecture could help out a mere Backbone.js programmer.
Eventually, I figured out two things. First, Flux is unopinionated
where it matters—the implementation specifics. Two, Flux is very
much like Backbone in the spirit of minimal moving parts that do
one thing well.
You don't need to know what Flux is or how it works to read 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.
Conventions
In this book, you will find a number of text styles that distinguish
between different kinds of information. Here are some examples of
these styles and an explanation of their meaning.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what
you think about this book—what you liked or disliked. Reader
feedback is important for us as it helps us develop titles that you
will really get the most out of.
If there is a topic that you have expertise in and you are interested
in either writing or contributing to a book, see our author guide at
www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a
number of things to help you to get the most from your purchase.
You can also download the code files by clicking on the Code Files
button on the book's webpage at the Packt Publishing website. This
page can be accessed by entering the book's name in the Search
box. Please note that you need to be logged in to your Packt
account.
Once the file is downloaded, please make sure that you unzip or
extract the folder using the latest version of:
Piracy
Piracy of copyrighted material on the Internet is an ongoing
problem across all media. At Packt, we take the protection of our
copyright and licenses very seriously. If you come across any illegal
copies of our works in any form on the Internet, please provide us
with the location address or website name immediately so that we
can pursue a remedy.
The aim of this chapter is to cut through the sales bullet points and
explicitly spell out what Flux is, and what it isn't, by looking at the
patterns that Flux provides. And since Flux isn't a software package
in the traditional sense, we'll go over the conceptual problems that
we're trying to solve with Flux.
* * * * *
Transcriber’s Notes: