Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Mar 23, 2023. It is now read-only.
/fluxPublic archive

Application Architecture for Building User Interfaces

License

NotificationsYou must be signed in to change notification settings

facebookarchive/flux

Repository files navigation

logo

Flux

An application architecture for React utilizing a unidirectional data flow.
Licence BadgeCurrent npm package version.


Getting Started

Start by looking through theguides and examples on Github. For more resources and API docs check outfacebook.github.io/flux.

How Flux works

For more information on how Flux works check out theFlux Concepts guide, or theIn Depth Overview.

Requirements

Flux is more of a pattern than a framework, and does not have any hard dependencies. However, we often useEventEmitter as a basis forStores andReact for ourViews. The one piece of Flux not readily available elsewhere is theDispatcher. This module, along with some other utilities, is available here to complete your Flux toolbox.

Installing Flux

Flux is available as anpm module, so you can add it to your package.json file or runnpm install flux. The dispatcher will be available asFlux.Dispatcher and can be required like this:

constDispatcher=require('flux').Dispatcher;

Take a look at thedispatcher API and some examples.

Flux Utils

We have also provided some basic utility classes to help get you started with Flux. These base classes are a solid foundation for a simple Flux application, but they arenot a feature-complete framework that will handle all use cases. There are many other great Flux frameworks out there if these utilities do not fulfill your needs.

import{ReduceStore}from'flux/utils';classCounterStoreextendsReduceStore<number>{getInitialState():number{    return0;}reduce(state:number,action:Object):number{switch(action.type){case'increment':returnstate+1;case'square':returnstate*state;      default:returnstate;}}}

Check out theexamples anddocumentation for more information.

Building Flux from a Cloned Repo

Clone the repo and navigate into the resultingflux directory. Then runnpm install.

This will runGulp-based build tasks automatically and produce the file Flux.js, which you can then require as a module.

You could then require the Dispatcher like so:

constDispatcher=require('path/to/this/directory/Flux').Dispatcher;

The build process also produces de-sugared versions of theDispatcher andinvariant modules in alib directory, and you can require those modules directly, copying them into whatever directory is most convenient for you. Theflux-todomvc andflux-chat example applications both do this.

License

Flux is BSD-licensed. We also provide an additional patent grant.


[8]ページ先頭

©2009-2025 Movatter.jp