{"_id":"s-flux","_rev":"6-a0cc3904df499995f4228a03796993cb","name":"s-flux","description":"A `simple flux` lib","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"s-flux","version":"0.0.1","description":"A `simple flux` lib","main":"index.js","keywords":["flux","simple flux","s-flux"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ccqgithub/s-flux.git"},"author":{"name":"ccqgithub"},"license":"ISC","bugs":{"url":"https://github.com/ccqgithub/s-flux/issues"},"homepage":"https://github.com/ccqgithub/s-flux#readme","gitHead":"4506ec93308be095af296debbd53ef2f0a56a698","_id":"s-flux@0.0.1","_shasum":"1ab858169ff9086d5adc732fac0a72c3d5626e1c","_from":".","_npmVersion":"3.8.8","_nodeVersion":"4.4.3","_npmUser":{"name":"sherry","email":"season.chen.i@foxmail.com"},"dist":{"shasum":"1ab858169ff9086d5adc732fac0a72c3d5626e1c","tarball":"https://registry.npmjs.org/s-flux/-/s-flux-0.0.1.tgz","integrity":"sha512-FEsPYIRkr/3obNDYReWtuHfRxgdxsZ3zNcDGNGDGF81ay4umRF1X+LNFjQXA498RnygK7WgYE2hvzJ5VxEG2iA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIACO0/hER9mJpMgQO9YcoT0jHQ9FvAZlk5rfFzbNj0nEAiAYqXC9TQ1XTo4F1SEhDwMiDiizwzPmNkULbMrIDvF0PA=="}]},"maintainers":[{"name":"sherry","email":"season.chen.i@foxmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/s-flux-0.0.1.tgz_1463297555443_0.5981162954121828"},"directories":{}},"0.0.2":{"name":"s-flux","version":"0.0.2","description":"A `simple flux` lib","main":"dist/s-flux.common.js","keywords":["flux","simple flux","s-flux"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ccqgithub/s-flux.git"},"author":{"name":"Season Chen"},"license":"ISC","bugs":{"url":"https://github.com/ccqgithub/s-flux/issues"},"homepage":"https://github.com/ccqgithub/s-flux#readme","devDependencies":{"rollup":"^0.26.3","rollup-plugin-babel":"^1.0.0","rollup-plugin-replace":"^1.1.0","uglify-js":"^2.6.2"},"gitHead":"4506ec93308be095af296debbd53ef2f0a56a698","_id":"s-flux@0.0.2","_shasum":"bf97b56ddb7c685ee1049d5fd85bd53f2111377b","_from":".","_npmVersion":"3.8.8","_nodeVersion":"4.4.3","_npmUser":{"name":"sherry","email":"season.chen.i@foxmail.com"},"dist":{"shasum":"bf97b56ddb7c685ee1049d5fd85bd53f2111377b","tarball":"https://registry.npmjs.org/s-flux/-/s-flux-0.0.2.tgz","integrity":"sha512-8HOHIkoRYk4l+1Wn+MnlGIq2ZkfwOl7Pa5n4QAr7vKBjQYuHmk7MGZtq/sfSaBRzxgctcaabhg/f2EUrWUn0Lw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDaXzjbEE999UaDkDg7RgnGV8WZZ1TTTlrqf0UfcURUygIhAJ+u7KqNyax1atrVMi16LlkwsK0tYbBD31+fa6K2AGYw"}]},"maintainers":[{"name":"sherry","email":"season.chen.i@foxmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/s-flux-0.0.2.tgz_1463308035782_0.3932660836726427"},"directories":{}},"0.0.3":{"name":"s-flux","version":"0.0.3","description":"A `simple flux` lib","main":"dist/s-flux.common.js","keywords":["flux","simple flux","s-flux"],"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/ccqgithub/s-flux.git"},"author":{"name":"Season Chen"},"license":"ISC","bugs":{"url":"https://github.com/ccqgithub/s-flux/issues"},"homepage":"https://github.com/ccqgithub/s-flux#readme","devDependencies":{"babel-core":"^6.11.4","babel-loader":"^6.2.4","babel-preset-es2015":"^6.9.0","uglify-js":"^2.6.2","webpack":"^1.13.1"},"dependencies":{"es6-promise":"^3.2.1","rollup-plugin-commonjs":"^3.3.1"},"gitHead":"e8f8d050e4b379a9718acc262f132180fb497780","_id":"s-flux@0.0.3","_shasum":"54308d8f3ca661ab8b381bfd1237d47a060f76cf","_from":".","_npmVersion":"3.4.0","_nodeVersion":"4.2.2","_npmUser":{"name":"sherry","email":"season.chen.i@foxmail.com"},"dist":{"shasum":"54308d8f3ca661ab8b381bfd1237d47a060f76cf","tarball":"https://registry.npmjs.org/s-flux/-/s-flux-0.0.3.tgz","integrity":"sha512-94H2IiHoFHiFDu2jvB5XThSX9JxhNecrYG9DjGIroEKgL3eLzeDu4Evepj9Htof/vVEQkn8Ig0z/3vBuIItUdQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICTulyS8KqDVI87wMSRYshA4p3nSiId2GFjJ2bm747gkAiEA+TmYQwRWYWX5nGBaV0JCaqZnQwQc9Gk80uFrE2cezPY="}]},"maintainers":[{"name":"sherry","email":"season.chen.i@foxmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/s-flux-0.0.3.tgz_1469958547552_0.8527822319883853"},"directories":{}}},"readme":"# s-flux：a simple flux lib (测试版)\n\n## 介绍\n\n> 一个简单的flux工具库，支持单页应用和多页应用，支持同步action和异步action。\n\n## 安装\n\n> 依赖'es6-promise', npm模块指向`dist/s-flux.common.js`。\n> `dist/s-flux.js`和`dis/s-flux.min.js`为浏览器直接引用，为UMD模块，`es6-promise`已经打包在内。\n\n- 浏览器直接引用：\n\n``` html\n<script src=\"s-flux/dist/s-flux.min.js\"></script>\n<script>\nvar Store = SFlux.Store;\nvar createAction = SFlux.createAction;\n//...\n</script>\n```\n\n- commonjs模块引用:\n\n``` js\nimport {Store, createAction} form 's-flux';\n// or\nvar SFlux = require('s-flux');\n```\n\n## API\n\n- Store: 数据仓库基类\n\n```javascript\n// app-store.js\nimport {Store} from 's-flux';\n\n// 创建一个store\nvar appStore = module.exports = new Store({\n  // 初始化状态\n  initialState = {},\n\n  // 数据更新: mutation => {type: 'mutation type', data: 'mutation data'}\n  mutation = function(state, mutation) {\n    return state;\n  },\n\n  // 子模块：{key: childStore}\n  modules = {},\n\n  // 中间件\n  middlewares = [],\n\n  // store名，便于调试用\n  name = 'store'\n});\n```\n\n- createMutationTypes: 创建一组数据更新常量\n\n``` javascript\n// mutation-types.js\nimport {createMutationTypes} from 's-flux';\n\nmodule.exports = createMutationTypes({\n  'INCREMENT',\n  'DECREMENT',\n  'OTHER',\n  'BEFORE_SUBMIT',\n  'SUBMIT'\n});\n```\n\n- createAction: 创建一个action\n\n``` javascript\n// actions.js\nimport {createAction} from 's-flux';\n\nexport var submit = createAction(function(params, {store, error, dispatch}) {\n  dispatch({\n    type: 'BEFORE_SUBMIT'\n  }, true);\n\n  //异步action\n  setTimeout(function() {\n    dispatch({\n      type: 'SUBMIT',\n      data: '111'\n    });\n  });\n});\n\n```\n\n- setGlobalStore: 注册一个全局store, 这样不要每次调用action的时候传入\n\n``` javascript\n// app.js\nimport {setGlobalStore} from 's-flux';\nimport appStore from './app-store';\nimport mutationTypes from './mutation-types';\nimport {submit} from './actions';\n\n// 注册全局store\nsetGlobalStore(appStore);\n\n// 调用action\nconsole.log('loading……')\nsubmit({})\n  .then(function(data) {\n    console.log('success……')\n  })\n  .catch(function(error) {\n    /console.log('error……')\n  });\n```\n","maintainers":[{"email":"season.chen.i@foxmail.com","name":"season.chen"}],"time":{"modified":"2022-06-26T15:08:32.492Z","created":"2016-05-15T07:32:38.478Z","0.0.1":"2016-05-15T07:32:38.478Z","0.0.2":"2016-05-15T10:27:18.986Z","0.0.3":"2016-07-31T09:49:11.994Z"},"homepage":"https://github.com/ccqgithub/s-flux#readme","keywords":["flux","simple flux","s-flux"],"repository":{"type":"git","url":"git+https://github.com/ccqgithub/s-flux.git"},"author":{"name":"Season Chen"},"bugs":{"url":"https://github.com/ccqgithub/s-flux/issues"},"license":"ISC","readmeFilename":"README.md"}