首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

redux-1.0.0-alpha.zip

前端 55.74KB 17 需要积分: 1
立即下载

资源介绍:

一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux ========================= [![build status](https://img.shields.io/travis/gaearon/redux/master.svg?style=flat-square)](https://travis-ci.org/gaearon/redux) [![npm version](https://img.shields.io/npm/v/redux.svg?style=flat-square)](https://www.npmjs.com/package/redux) [![redux channel on slack](https://img.shields.io/badge/slack-redux@reactiflux-61DAFB.svg?style=flat-square)](http://www.reactiflux.com) Atomic Flux with hot reloading. **The API is likely to change a few times before we reach 1.0.**
**Its [surface area](http://www.youtube.com/watch?v=4anAwXYqLG8) is minimal so you can try it in production and report any issues.** # Table of Contents - [Why another Flux framework?](#why-another-flux-framework) - [Philosophy & Design Goals](#philosophy--design-goals) - [Demo](#demo) - [Examples](#examples) - [Simple Examples](#simple-examples) - [Async and Universal Examples with Routing](#async-and-universal-examples-with-routing) - [What does it look like?](#what-does-it-look-like) - [Actions](#actions) - [Stores](#stores) - [Components](#components) - [Dumb Components](#dumb-components) - [Smart Components](#smart-components) - [Decorators](#decorators) - [React Native](#react-native) - [Initializing Redux](#initializing-redux) - [Running the same code on client and server](#running-the-same-code-on-client-and-server) - [Additional customization](#additional-customization) - [FAQ](#faq) - [How does hot reloading work?](#how-does-hot-reloading-work) - [Can I use this in production?](#can-i-use-this-in-production) - [How do I do async?](#how-do-i-do-async) - [But there are switch statements!](#but-there-are-switch-statements) - [What about `waitFor`?](#what-about-waitfor) - [My views aren't updating!](#my-views-arent-updating) - [How do Stores, Actions and Components interact?](#how-do-stores-actions-and-components-interact) - [Discussion](#discussion) - [Inspiration and Thanks](#inspiration-and-thanks) ## Why another Flux framework? Read **[The Evolution of Flux Frameworks](https://medium.com/@dan_abramov/the-evolution-of-flux-frameworks-6c16ad26bb31)** for some context. ### Philosophy & Design Goals * You shouldn't need a book on functional programming to use Redux. * Everything (Stores, Action Creators, configuration) is hot reloadable. * Preserves the benefits of Flux, but adds other nice properties thanks to its functional nature. * Prevents some of the anti-patterns common in Flux code. * Works great in [universal (aka “isomorphic”)](https://medium.com/@mjackson/universal-javascript-4761051b7ae9) apps because it doesn't use singletons and the data can be rehydrated. * Doesn't care how you store your data: you may use JS objects, arrays, ImmutableJS, etc. * Under the hood, it keeps all your data in a tree, but you don't need to think about it. * Lets you efficiently subscribe to finer-grained updates than individual Stores. * Provides hooks for powerful devtools (e.g. time travel, record/replay) to be implementable without user buy-in. * Provides extension points so it's easy to [support promises](https://github.com/gaearon/redux/issues/99#issuecomment-112212639) or [generate constants](https://gist.github.com/skevy/8a4ffc3cfdaf5fd68739) outside the core. * No wrapper calls in your stores and actions. Your stuff is your stuff. * It's super easy to test things in isolation without mocks. * You can use “flat” Stores, or [compose and reuse Stores](https://gist.github.com/gaearon/d77ca812015c0356654f) just like you compose Components. * The API surface area is minimal. * Have I mentioned hot reloading yet? ## Demo ## Examples ### Simple Examples Redux is distributed with a Counter and a TodoMVC example in its source code. First, clone the repo: ``` git clone https://github.com/gaearon/redux.git cd redux ``` Run the Counter example: ``` cd redux/examples/counter npm install npm start ``` Run the TodoMVC example: ``` cd ../todomvc npm install npm start ``` ### Async and Universal Examples with Routing These async and [universal (aka “isomorphic”)](https://medium.com/@mjackson/universal-javascript-4761051b7ae9) examples using React Router should help you get started: * [redux-react-router-async-example](https://github.com/emmenko/redux-react-router-async-example): Work in progress. Semi-official. Only the client side. Uses React Router. * [react-redux-universal-hot-example](https://github.com/erikras/react-redux-universal-hot-example): Universal. Uses React Router. * [redux-example](https://github.com/quangbuule/redux-example): Universal. Uses Immutable, React Router. * [isomorphic-counter-example](https://github.com/khtdr/redux-react-koa-isomorphic-counter-example): Universal. A bare-bone implentation of the [counter example app](https://github.com/gaearon/redux/tree/master/examples/counter). Uses promises-middleware to interact with API via Koa on the server. Don’t be shy, add your own! ## What does it look like? ### Actions ```js // Still using constants... import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../constants/ActionTypes'; // But action creators are pure functions returning actions export function increment() { return { type: INCREMENT_COUNTER }; } export function decrement() { return { type: DECREMENT_COUNTER }; } // Can also be async if you return a function export function incrementAsync() { return dispatch => { setTimeout(() => { // Yay! Can invoke sync or async actions with `dispatch` dispatch(increment()); }, 1000); }; } // Could also read state of a store in the callback form export function incrementIfOdd() { return (dispatch, getState) => { const { counter } = getState(); if (counter % 2 === 0) { return; } dispatch(increment()); }; } ``` ### Stores ```js // ... too, use constants import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../constants/ActionTypes'; // what's important is that Store is a pure function, // and you can write it anyhow you like. // the Store signature is (state, action) => state, // and the state shape is up to you: you can use primitives, // objects, arrays, or even ImmutableJS objects. export default function counter(state = 0, action) { // this function returns the new state when an action comes switch (action.type) { case INCREMENT_COUNTER: return state + 1; case DECREMENT_COUNTER: return state - 1; default: return state; } // BUT THAT'S A SWITCH STATEMENT! // Right. If you hate 'em, see the FAQ below. } ``` ### Components #### Dumb Components ```js // The dumb component receives everything using props: import React, { PropTypes } from 'react'; export default class Counter { static propTypes = { increment: PropTypes.func.isRequired, decrement: PropTypes.func.isRequired, counter: PropTypes.number.isRequired }; render() { const { increment, decrement, counter } = this.props; return (

Clicked: {counter} times {' '} {' '}

); } } ``` #### Smart Components ```js // The smart component may observe stores using ``, // and bind actions to the dispatcher with `bindActionCreators`. import React from 'react'; import { bindActionCreators } from 'redux'; import { Connector } from 'redux/react'; import Counter from '../components/Counter'; import * as CounterActions from '../actions/CounterActions'; // You can optionally specify `select` for finer-grained subscriptions // and retrieval. Only when the return value is shallowly different, // will the child component be updated. function select(state) { return { counter: state.counter }; } export default class CounterApp { render() { retu

资源文件列表:

redux-1.0.0-alpha.zip 大约有119个文件
  1. redux-1.0.0-alpha/
  2. redux-1.0.0-alpha/.babelrc 35B
  3. redux-1.0.0-alpha/.eslintignore 201B
  4. redux-1.0.0-alpha/.eslintrc 473B
  5. redux-1.0.0-alpha/.gitignore 80B
  6. redux-1.0.0-alpha/.npmignore 13B
  7. redux-1.0.0-alpha/.travis.yml 38B
  8. redux-1.0.0-alpha/CHANGELOG.md 13.24KB
  9. redux-1.0.0-alpha/LICENSE 1.05KB
  10. redux-1.0.0-alpha/README.md 17.54KB
  11. redux-1.0.0-alpha/ROADMAP.md 382B
  12. redux-1.0.0-alpha/docs/
  13. redux-1.0.0-alpha/docs/middleware.md 2.77KB
  14. redux-1.0.0-alpha/examples/
  15. redux-1.0.0-alpha/examples/counter/
  16. redux-1.0.0-alpha/examples/counter/.babelrc 17B
  17. redux-1.0.0-alpha/examples/counter/actions/
  18. redux-1.0.0-alpha/examples/counter/actions/CounterActions.js 559B
  19. redux-1.0.0-alpha/examples/counter/components/
  20. redux-1.0.0-alpha/examples/counter/components/Counter.js 645B
  21. redux-1.0.0-alpha/examples/counter/constants/
  22. redux-1.0.0-alpha/examples/counter/constants/ActionTypes.js 108B
  23. redux-1.0.0-alpha/examples/counter/containers/
  24. redux-1.0.0-alpha/examples/counter/containers/App.js 363B
  25. redux-1.0.0-alpha/examples/counter/containers/CounterApp.js 487B
  26. redux-1.0.0-alpha/examples/counter/index.html 169B
  27. redux-1.0.0-alpha/examples/counter/index.js 126B
  28. redux-1.0.0-alpha/examples/counter/package.json 833B
  29. redux-1.0.0-alpha/examples/counter/server.js 420B
  30. redux-1.0.0-alpha/examples/counter/stores/
  31. redux-1.0.0-alpha/examples/counter/stores/counter.js 291B
  32. redux-1.0.0-alpha/examples/counter/stores/index.js 48B
  33. redux-1.0.0-alpha/examples/counter/webpack.config.js 607B
  34. redux-1.0.0-alpha/examples/todomvc/
  35. redux-1.0.0-alpha/examples/todomvc/.babelrc 17B
  36. redux-1.0.0-alpha/examples/todomvc/actions/
  37. redux-1.0.0-alpha/examples/todomvc/actions/TodoActions.js 561B
  38. redux-1.0.0-alpha/examples/todomvc/components/
  39. redux-1.0.0-alpha/examples/todomvc/components/Footer.js 1.75KB
  40. redux-1.0.0-alpha/examples/todomvc/components/Header.js 550B
  41. redux-1.0.0-alpha/examples/todomvc/components/MainSection.js 2.11KB
  42. redux-1.0.0-alpha/examples/todomvc/components/TodoItem.js 1.64KB
  43. redux-1.0.0-alpha/examples/todomvc/components/TodoTextInput.js 1.26KB
  44. redux-1.0.0-alpha/examples/todomvc/constants/
  45. redux-1.0.0-alpha/examples/todomvc/constants/ActionTypes.js 234B
  46. redux-1.0.0-alpha/examples/todomvc/constants/TodoFilters.js 124B
  47. redux-1.0.0-alpha/examples/todomvc/containers/
  48. redux-1.0.0-alpha/examples/todomvc/containers/App.js 354B
  49. redux-1.0.0-alpha/examples/todomvc/containers/TodoApp.js 692B
  50. redux-1.0.0-alpha/examples/todomvc/index.html 177B
  51. redux-1.0.0-alpha/examples/todomvc/index.js 162B
  52. redux-1.0.0-alpha/examples/todomvc/package.json 962B
  53. redux-1.0.0-alpha/examples/todomvc/server.js 420B
  54. redux-1.0.0-alpha/examples/todomvc/stores/
  55. redux-1.0.0-alpha/examples/todomvc/stores/index.js 44B
  56. redux-1.0.0-alpha/examples/todomvc/stores/todos.js 1.04KB
  57. redux-1.0.0-alpha/examples/todomvc/webpack.config.js 671B
  58. redux-1.0.0-alpha/package.json 1.48KB
  59. redux-1.0.0-alpha/scripts/
  60. redux-1.0.0-alpha/scripts/browser 293B
  61. redux-1.0.0-alpha/scripts/build 140B
  62. redux-1.0.0-alpha/scripts/clean 34B
  63. redux-1.0.0-alpha/scripts/lint 46B
  64. redux-1.0.0-alpha/scripts/prepublish 83B
  65. redux-1.0.0-alpha/scripts/test 82B
  66. redux-1.0.0-alpha/scripts/test-cov 97B
  67. redux-1.0.0-alpha/scripts/test-watch 90B
  68. redux-1.0.0-alpha/src/
  69. redux-1.0.0-alpha/src/Redux.js 1.27KB
  70. redux-1.0.0-alpha/src/components/
  71. redux-1.0.0-alpha/src/components/createAll.js 594B
  72. redux-1.0.0-alpha/src/components/createConnectDecorator.js 802B
  73. redux-1.0.0-alpha/src/components/createConnector.js 2.2KB
  74. redux-1.0.0-alpha/src/components/createProvideDecorator.js 581B
  75. redux-1.0.0-alpha/src/components/createProvider.js 1010B
  76. redux-1.0.0-alpha/src/createDispatcher.js 629B
  77. redux-1.0.0-alpha/src/createRedux.js 321B
  78. redux-1.0.0-alpha/src/entry-react-native.js 36B
  79. redux-1.0.0-alpha/src/entry-react.js 29B
  80. redux-1.0.0-alpha/src/index.js 392B
  81. redux-1.0.0-alpha/src/middleware/
  82. redux-1.0.0-alpha/src/middleware/thunk.js 228B
  83. redux-1.0.0-alpha/src/react-native.js 158B
  84. redux-1.0.0-alpha/src/react.js 151B
  85. redux-1.0.0-alpha/src/umd-react.js 50B
  86. redux-1.0.0-alpha/src/umd.js 25B
  87. redux-1.0.0-alpha/src/utils/
  88. redux-1.0.0-alpha/src/utils/bindActionCreators.js 225B
  89. redux-1.0.0-alpha/src/utils/composeMiddleware.js 126B
  90. redux-1.0.0-alpha/src/utils/composeStores.js 345B
  91. redux-1.0.0-alpha/src/utils/createReduxShape.js 212B
  92. redux-1.0.0-alpha/src/utils/getDisplayName.js 119B
  93. redux-1.0.0-alpha/src/utils/identity.js 60B
  94. redux-1.0.0-alpha/src/utils/isPlainObject.js 146B
  95. redux-1.0.0-alpha/src/utils/mapValues.js 165B
  96. redux-1.0.0-alpha/src/utils/pick.js 183B
  97. redux-1.0.0-alpha/src/utils/shallowEqual.js 496B
  98. redux-1.0.0-alpha/src/utils/shallowEqualScalar.js 757B
  99. redux-1.0.0-alpha/test/
  100. redux-1.0.0-alpha/test/_helpers.js 741B
  101. redux-1.0.0-alpha/test/components/
  102. redux-1.0.0-alpha/test/components/Connector.spec.js 6.54KB
  103. redux-1.0.0-alpha/test/components/Provider.spec.js 1.8KB
  104. redux-1.0.0-alpha/test/components/connect.spec.js 1.93KB
  105. redux-1.0.0-alpha/test/components/jsdomReact.js 194B
  106. redux-1.0.0-alpha/test/components/provide.spec.js 1.73KB
  107. redux-1.0.0-alpha/test/composeMiddleware.spec.js 651B
  108. redux-1.0.0-alpha/test/composeStores.spec.js 1019B
  109. redux-1.0.0-alpha/test/createDispatcher.spec.js 1.39KB
  110. redux-1.0.0-alpha/test/createRedux.spec.js 1.98KB
  111. redux-1.0.0-alpha/test/getDisplayName.spec.js 410B
  112. redux-1.0.0-alpha/test/utils/
  113. redux-1.0.0-alpha/test/utils/bindActionCreators.spec.js 1023B
  114. redux-1.0.0-alpha/test/utils/identity.spec.js 294B
  115. redux-1.0.0-alpha/test/utils/isPlainObject.spec.js 591B
  116. redux-1.0.0-alpha/test/utils/mapValues.spec.js 349B
  117. redux-1.0.0-alpha/test/utils/pick.spec.js 332B
  118. redux-1.0.0-alpha/test/utils/shallowEquality.spec.js 3.18KB
  119. redux-1.0.0-alpha/webpack.config.js 859B
0评论
提交 加载更多评论
其他资源 redux-1.0.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-2.1.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-2.1.2.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-1.0.1.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-0.11.1.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-1.0.0-rc.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-0.12.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-0.11.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management