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

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

redux-0.3.0.zip

前端 14.17KB 15 需要积分: 1
立即下载

资源介绍:

一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux ========================= An experiment in fully hot-reloadable Flux. **The API might change any day.** _**Don't use in production.**_ ## Why another Flux framework? Read **[The Evolution of Flux Frameworks](https://medium.com/@dan_abramov/the-evolution-of-flux-frameworks-6c16ad26bb31)** for some context. ### Design Goals * Hot reloading of everything. * A hook for the future devtools to "commit" a state, and replay actions on top of it during hot reload. * No `createAction`, `createStores`, `wrapThisStuff`. Your stuff is your stuff. * I don't mind action constants. Seriously. * Keep Flux lingo. No cursors or observables in core. * Have I mentioned hot reloading yet? ## Demo ``` git clone https://github.com/gaearon/redux.git redux cd redux npm install npm start ``` ## What's 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 // (wow, much functions, so injectable :doge:) export function incrementAsync() { return dispatch => { setTimeout(() => { dispatch(increment()); }, 1000); }; } // Could also look into state in the callback form export function incrementIfOdd() { return (dispatch, state) => { if (state.counterStore.counter % 2 === 0) { return; } dispatch(increment()); }; } ``` ### Stores ```js // ... too, use constants import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../constants/ActionTypes'; // but you can write this part anyhow you like: const initialState = { counter: 0 }; function increment({ counter }) { return { counter: counter + 1 }; } function decrement({ counter }) { return { counter: counter - 1 }; } // what's important is that Store is a pure function too export default function counterStore(state = initialState, action) { // that returns the new state when an action comes switch (action.type) { case INCREMENT_COUNTER: return increment(state, action); case DECREMENT_COUNTER: return decrement(state, action); default: return state; } } // bonus: no special support needed for ImmutableJS, // just return its objects as the state. ``` ### Components #### Dumb Components ```js // The dumb component receives everything using props: import React, { PropTypes } from 'react'; export default class Counter { static propTypes = { counter: PropTypes.number.isRequired, increment: PropTypes.func.isRequired, decrement: PropTypes.func.isRequired }; render() { const { counter } = this.props; return (

Clicked: {counter} times

); } } ``` #### Smart Components ```js // The smart component may inject actions // and observe stores using : import React, { Component } from 'react'; import { Root, Container } from 'redux'; import { increment, decrement } from './actions/CounterActions'; import counterStore from './stores/counterStore'; import Counter from './Counter'; export default class CounterContainer { render() { // stores can be a single store or an array. // actions can only be a string -> function map. // props passed to children will combine these actions and state. return ( {props => } ); } } ``` #### The root component ```js import React from 'react'; import { Root } from 'redux'; @Root export default class App { /* ... */ } ``` ## FAQ ### How does hot reloading work? * http://webpack.github.io/docs/hot-module-replacement.html * http://gaearon.github.io/react-hot-loader/ * those `module.hot` lines in the dispatcher example above ### Can I use this in production? I wouldn't. Many use cases are not be considered yet. If you find some use cases this lib can't handle yet, please file an issue.

资源文件列表:

redux-0.3.0.zip 大约有41个文件
  1. redux-0.3.0/
  2. redux-0.3.0/.babelrc 43B
  3. redux-0.3.0/.eslintrc 349B
  4. redux-0.3.0/.gitignore 40B
  5. redux-0.3.0/.jshintrc 75B
  6. redux-0.3.0/.npmignore 13B
  7. redux-0.3.0/LICENSE 1.05KB
  8. redux-0.3.0/README.md 4.08KB
  9. redux-0.3.0/TODO 148B
  10. redux-0.3.0/examples/
  11. redux-0.3.0/examples/counter/
  12. redux-0.3.0/examples/counter/App.js 475B
  13. redux-0.3.0/examples/counter/Counter.js 517B
  14. redux-0.3.0/examples/counter/actions/
  15. redux-0.3.0/examples/counter/actions/CounterActions.js 542B
  16. redux-0.3.0/examples/counter/constants/
  17. redux-0.3.0/examples/counter/constants/ActionTypes.js 108B
  18. redux-0.3.0/examples/counter/stores/
  19. redux-0.3.0/examples/counter/stores/counterStore.js 523B
  20. redux-0.3.0/examples/index.html 157B
  21. redux-0.3.0/examples/index.js 206B
  22. redux-0.3.0/examples/server.js 395B
  23. redux-0.3.0/examples/todo/
  24. redux-0.3.0/examples/todo/App.js 530B
  25. redux-0.3.0/examples/todo/Body.js 216B
  26. redux-0.3.0/examples/todo/Header.js 243B
  27. redux-0.3.0/examples/todo/actions/
  28. redux-0.3.0/examples/todo/actions/index.js 133B
  29. redux-0.3.0/examples/todo/constants/
  30. redux-0.3.0/examples/todo/constants/ActionTypes.js 35B
  31. redux-0.3.0/examples/todo/stores/
  32. redux-0.3.0/examples/todo/stores/index.js 383B
  33. redux-0.3.0/examples/webpack.config.js 742B
  34. redux-0.3.0/package.json 1.11KB
  35. redux-0.3.0/scripts/
  36. redux-0.3.0/scripts/build 53B
  37. redux-0.3.0/src/
  38. redux-0.3.0/src/Container.js 1.7KB
  39. redux-0.3.0/src/Root.js 706B
  40. redux-0.3.0/src/createDispatcher.js 3.13KB
  41. redux-0.3.0/src/index.js 64B
0评论
提交 加载更多评论
其他资源 redux-0.5.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-0.3.1.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-0.2.2.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-2.0.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-0.4.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
redux-0.2.1.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management
Idea-Tools插件
属于idea的插件,开发者可以通过此插件进行idea的插件开发,并提供完整的插件生命周期管理,方便使用者和开发者管理插件
redux-0.2.0.zip
一个可预测的全局状态管理的 JS 库 A JS library for predictable global state management