redux-interactions
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -9,3 +9,3 @@ import * as types from './types'; | ||
export default class Interactions { | ||
defaultState: any; | ||
initialState: any; | ||
_interactionReducers: { | ||
@@ -12,0 +12,0 @@ [key: string]: types.Reducer; |
@@ -12,3 +12,3 @@ "use strict"; | ||
function Interactions() { | ||
this.defaultState = Object.create(null); | ||
this.initialState = Object.create(null); | ||
// Register the class as a property of the instance so it is "exported" | ||
@@ -26,2 +26,4 @@ // under normal use. | ||
} | ||
// As well as the public _instance_ API inherited from us. | ||
this.reducer = this.reducer.bind(this); | ||
} | ||
@@ -32,3 +34,3 @@ /** | ||
Interactions.prototype.reducer = function (state, action) { | ||
state = state === undefined ? this.defaultState : state; | ||
state = state === undefined ? this.initialState : state; | ||
if (!this._interactionReducers) | ||
@@ -35,0 +37,0 @@ return state; |
@@ -10,3 +10,3 @@ "use strict"; | ||
describe("constructor", function () { | ||
it("defaults defaultState to an empty object", function () { | ||
it("defaults initialState to an empty object", function () { | ||
var instance = new (function (_super) { | ||
@@ -19,4 +19,4 @@ __extends(Simple, _super); | ||
}(src_1.Interactions)); | ||
expect(instance.defaultState).to.eql({}); | ||
expect(Object.getPrototypeOf(instance.defaultState)).to.equal(null); | ||
expect(instance.initialState).to.eql({}); | ||
expect(Object.getPrototypeOf(instance.initialState)).to.equal(null); | ||
}); | ||
@@ -161,3 +161,3 @@ it("exposes the class by its name", function () { | ||
}); | ||
it("honors defaultState", function () { | ||
it("honors initialState", function () { | ||
var instance = new (function (_super) { | ||
@@ -167,3 +167,3 @@ __extends(Simple, _super); | ||
_super.apply(this, arguments); | ||
this.defaultState = 123; | ||
this.initialState = 123; | ||
} | ||
@@ -199,3 +199,16 @@ return Simple; | ||
}); | ||
it("is callable when detached from its instance", function () { | ||
var Simple = (function (_super) { | ||
__extends(Simple, _super); | ||
function Simple() { | ||
_super.apply(this, arguments); | ||
} | ||
return Simple; | ||
}(src_1.Interactions)); | ||
Simple.addInteractionReducer('add', function (s) { return s + 1; }); | ||
var instance = new Simple; | ||
var reducer = instance.reducer; | ||
expect(reducer(1, { type: instance['ADD'], args: [1] })).to.eql(2); | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "redux-interactions", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A streamlined approach to managing your Redux action creators and reducers.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/convoyinc/redux-interactions", |
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
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
28888
533