Skip to content

Commit

Permalink
Add option to initialise with known state
Browse files Browse the repository at this point in the history
  • Loading branch information
glenjamin committed May 31, 2015
1 parent 1136c68 commit 8ee6e69
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 4 additions & 2 deletions flux-redux.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ exports.createDispatcher = createDispatcher;
exports.createStore = createStore;
exports.createInterceptor = createInterceptor;

function createDispatcher() {
function createDispatcher(options) {

var state = {};
options = options || {};

var state = options.state || {};
var stores = {};
var interceptors = {};
var listeners = {};
Expand Down
19 changes: 19 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,23 @@ describe("flux-redux", function() {
it("should only call first matching interceptor");
it("should do everything else the same");
});

describe("rehydration", function() {
var store;
beforeEach(function() {
store = redux.createStore(
function() { return 0; },
{ INC: function(n) { return n + 1; } }
);
flux.addStore('store', store);
s.stub(console, 'warn');
});

it("should begin with state if told to", function() {
flux.dispatch("INC");
var newFlux = redux.createDispatcher({ state: flux.get() });
newFlux.addStore('store', store);
expect(newFlux.get()).to.deep.eql(flux.get());
});
});
});

0 comments on commit 8ee6e69

Please sign in to comment.