Comparing version 0.9.0 to 0.10.0
'use strict'; | ||
var _toConsumableArray = require('babel-runtime/helpers/to-consumable-array')['default']; | ||
var _Object$defineProperty = require('babel-runtime/core-js/object/define-property')['default']; | ||
var _interopRequireDefault = require('babel-runtime/helpers/interop-require-default')['default']; | ||
_Object$defineProperty(exports, '__esModule', { | ||
@@ -11,3 +15,9 @@ value: true | ||
var _utilsComposeMiddleware = require('./utils/composeMiddleware'); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
function createDispatcher(store) { | ||
var middlewares = arguments[1] === undefined ? [] : arguments[1]; | ||
return function dispatcher(initialState, setState) { | ||
@@ -17,3 +27,3 @@ var state = store(initialState, {}); | ||
function dispatchSync(action) { | ||
function dispatch(action) { | ||
state = store(state, action); | ||
@@ -24,7 +34,11 @@ setState(state); | ||
function dispatch(action) { | ||
return typeof action === 'function' ? action(dispatch, state) : dispatchSync(action); | ||
function getState() { | ||
return state; | ||
} | ||
return dispatch; | ||
if (typeof middlewares === 'function') { | ||
middlewares = middlewares(getState); | ||
} | ||
return _utilsComposeMiddleware2['default'].apply(undefined, _toConsumableArray(middlewares).concat([dispatch])); | ||
}; | ||
@@ -31,0 +45,0 @@ } |
@@ -24,32 +24,10 @@ // Core | ||
// Wrapper components | ||
// Utilities | ||
var _componentsProvider = require('./components/Provider'); | ||
var _utilsComposeMiddleware = require('./utils/composeMiddleware'); | ||
var _componentsProvider2 = _interopRequireDefault(_componentsProvider); | ||
var _utilsComposeMiddleware2 = _interopRequireDefault(_utilsComposeMiddleware); | ||
exports.Provider = _componentsProvider2['default']; | ||
exports.compose = _utilsComposeMiddleware2['default']; | ||
var _componentsConnector = require('./components/Connector'); | ||
var _componentsConnector2 = _interopRequireDefault(_componentsConnector); | ||
exports.Connector = _componentsConnector2['default']; | ||
// Higher-order components (decorators) | ||
var _componentsProvide = require('./components/provide'); | ||
var _componentsProvide2 = _interopRequireDefault(_componentsProvide); | ||
exports.provide = _componentsProvide2['default']; | ||
var _componentsConnect = require('./components/connect'); | ||
var _componentsConnect2 = _interopRequireDefault(_componentsConnect); | ||
exports.connect = _componentsConnect2['default']; | ||
// Utilities | ||
var _utilsComposeStores = require('./utils/composeStores'); | ||
@@ -56,0 +34,0 @@ |
@@ -23,2 +23,6 @@ 'use strict'; | ||
var _middlewareThunk = require('./middleware/thunk'); | ||
var _middlewareThunk2 = _interopRequireDefault(_middlewareThunk); | ||
var Redux = (function () { | ||
@@ -30,3 +34,5 @@ function Redux(dispatcher, initialState) { | ||
// A shortcut notation to use the default dispatcher | ||
dispatcher = (0, _createDispatcher2['default'])((0, _utilsComposeStores2['default'])(dispatcher)); | ||
dispatcher = (0, _createDispatcher2['default'])((0, _utilsComposeStores2['default'])(dispatcher), function (getState) { | ||
return [(0, _middlewareThunk2['default'])(getState)]; | ||
}); | ||
} | ||
@@ -71,9 +77,9 @@ | ||
value: function subscribe(listener) { | ||
var _this = this; | ||
var listeners = this.listeners; | ||
this.listeners.push(listener); | ||
listeners.push(listener); | ||
return function () { | ||
var index = _this.listeners.indexOf(listener); | ||
_this.listeners.splice(index, 1); | ||
return function unsubscribe() { | ||
var index = listeners.indexOf(listener); | ||
listeners.splice(index, 1); | ||
}; | ||
@@ -80,0 +86,0 @@ } |
{ | ||
"name": "redux", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "An experiment in fully hot-reloadable Flux", | ||
@@ -9,5 +9,8 @@ "main": "lib/index.js", | ||
"clean": "rimraf ./lib", | ||
"lint": "eslint src", | ||
"lint": "eslint src test", | ||
"prepublish": "npm run clean && npm run build", | ||
"start": "cd examples && node server.js" | ||
"start": "cd examples && node server.js", | ||
"test": "NODE_ENV=test mocha --compilers js:babel/register --recursive", | ||
"test:watch": "npm run test -- --watch", | ||
"test:cov": "istanbul cover node_modules/.bin/_mocha -- --compilers js:babel/register --recursive" | ||
}, | ||
@@ -42,2 +45,8 @@ "repository": { | ||
"eslint-plugin-react": "^2.3.0", | ||
"expect": "^1.6.0", | ||
"istanbul": "^0.3.15", | ||
"jsdom": "~5.4.3", | ||
"mocha": "^2.2.5", | ||
"mocha-jsdom": "~0.4.0", | ||
"react": "^0.13.0", | ||
"react-hot-loader": "^1.2.7", | ||
@@ -52,4 +61,3 @@ "rimraf": "^2.3.4", | ||
"invariant": "^2.0.0", | ||
"lodash": "^3.9.3", | ||
"react": "^0.13.0" | ||
"lodash": "^3.9.3" | ||
}, | ||
@@ -56,0 +64,0 @@ "browserify": { |
redux | ||
========================= | ||
[![build status](https://img.shields.io/travis/gaearon/redux.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) | ||
An experiment in fully hot-reloadable Flux. | ||
**The API might change any day.** | ||
_**Don't use in production.**_ | ||
_**Don't use in production just yet.**_ | ||
@@ -185,2 +188,4 @@ ## Why another Flux framework? | ||
const { counter, dispatch } = this.props; | ||
// Instead of `bindActionCreators`, you may also pass `dispatch` as a prop | ||
// to your component and call `dispatch(CounterActions.increment())` | ||
return ( | ||
@@ -255,2 +260,3 @@ <Counter counter={counter} | ||
import { createRedux, createDispatcher, composeStores } from 'redux'; | ||
import thunkMiddleware from 'redux/lib/middleware/thunk'; | ||
import * as stores from '../stores/index'; | ||
@@ -262,3 +268,6 @@ | ||
// Create a Dispatcher function for your composite Store: | ||
const dispatcher = createDispatcher(store); | ||
const dispatcher = createDispatcher( | ||
store, | ||
getState => [thunkMiddleware(getState)] // Pass the default middleware | ||
); | ||
@@ -271,2 +280,4 @@ // Create a Redux instance using the dispatcher function: | ||
`createDispatcher()` also gives you the ability to specify middleware -- for example, to add support for promises. [Learn more](https://github.com/gaearon/redux/blob/master/docs/middleware.md) about how to create and use middleware in Redux. | ||
When in doubt, use the shorter option! | ||
@@ -343,1 +354,16 @@ | ||
[Read more](https://github.com/sebmarkbage/ecmascript-rest-spread) about the spread properties ES7 proposal. | ||
## Inspiration and Thanks | ||
* [Webpack](https://github.com/webpack/docs/wiki/hot-module-replacement-with-webpack) for Hot Module Replacement | ||
* [The Elm Architecture](https://github.com/evancz/elm-architecture-tutorial) for a great intro to “stateless Stores” | ||
* [Turning the database inside-out](http://blog.confluent.io/2015/03/04/turning-the-database-inside-out-with-apache-samza/) for blowing my mind | ||
* [Developing ClojureScript with Figwheel](http://www.youtube.com/watch?v=j-kj2qwJa_E) for convincing me that re-evaluation should “just work” | ||
* [Flummox](https://github.com/acdlite/flummox) for teaching me to approach Flux without boilerplate or singletons | ||
* [disto](https://github.com/threepointone/disto) for a proof of concept of hot reloadable Stores | ||
* [NuclearJS](https://github.com/optimizely/nuclear-js) for proving this architecture can be performant | ||
* [Om](https://github.com/omcljs/om) for popularizing the idea of a single state atom | ||
* [Cycle](https://github.com/staltz/cycle) for showing how often a function is the best tool | ||
* [React](https://github.com/facebook/react) for the pragmatic innovation | ||
Special thanks go to [Jamie Paton](http://jdpaton.github.io/) for handing over the `redux` NPM package name. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140983
4
51
1490
365
16
1
2
- Removedreact@^0.13.0
- Removedreact@0.13.3(transitive)