Comparing version 0.15.2 to 0.15.3
# Changelog | ||
## 0.15.3 | ||
Added: | ||
* Define your actions as POJO. [commit](https://github.com/goatslacker/alt/commit/d99a872) | ||
* Use generateActions with alt instances. [commit](https://github.com/goatslacker/alt/commit/06d07e1) | ||
## 0.15.2 | ||
@@ -4,0 +11,0 @@ |
@@ -1474,40 +1474,48 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Alt = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var actions = assign({}, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
var actions = {}; | ||
var key = ActionsClass.name || ActionsClass.displayName || ""; | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
_classCallCheck(this, ActionsGenerator); | ||
if (typeof ActionsClass === "function") { | ||
(function () { | ||
assign(actions, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
_get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
_classCallCheck(this, ActionsGenerator); | ||
_inherits(ActionsGenerator, _ActionsClass); | ||
_get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
_createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
_inherits(ActionsGenerator, _ActionsClass); | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
_createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
} | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
new ActionsGenerator(this); | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
new ActionsGenerator(_this8); | ||
})(); | ||
} else { | ||
assign(actions, ActionsClass); | ||
} | ||
return Object.keys(actions).reduce(function (obj, action) { | ||
@@ -1599,3 +1607,3 @@ var constant = formatAsConstant(action); | ||
value: function addActions(name, ActionsClass) { | ||
this.actions[name] = this.createActions(ActionsClass); | ||
this.actions[name] = Array.isArray(ActionsClass) ? this.generateActions.apply(this, ActionsClass) : this.createActions(ActionsClass); | ||
} | ||
@@ -1602,0 +1610,0 @@ }, |
@@ -1218,40 +1218,48 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Alt = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var actions = assign({}, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
var actions = {}; | ||
var key = ActionsClass.name || ActionsClass.displayName || ""; | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
_classCallCheck(this, ActionsGenerator); | ||
if (typeof ActionsClass === "function") { | ||
(function () { | ||
assign(actions, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
_get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
_classCallCheck(this, ActionsGenerator); | ||
_inherits(ActionsGenerator, _ActionsClass); | ||
_get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
_createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
_inherits(ActionsGenerator, _ActionsClass); | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
_createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
} | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
new ActionsGenerator(this); | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
new ActionsGenerator(_this8); | ||
})(); | ||
} else { | ||
assign(actions, ActionsClass); | ||
} | ||
return Object.keys(actions).reduce(function (obj, action) { | ||
@@ -1343,3 +1351,3 @@ var constant = formatAsConstant(action); | ||
value: function addActions(name, ActionsClass) { | ||
this.actions[name] = this.createActions(ActionsClass); | ||
this.actions[name] = Array.isArray(ActionsClass) ? this.generateActions.apply(this, ActionsClass) : this.createActions(ActionsClass); | ||
} | ||
@@ -1346,0 +1354,0 @@ }, |
@@ -469,38 +469,46 @@ "use strict"; | ||
var actions = assign({}, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
var actions = {}; | ||
var key = ActionsClass.name || ActionsClass.displayName || ""; | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
babelHelpers.classCallCheck(this, ActionsGenerator); | ||
if (typeof ActionsClass === "function") { | ||
(function () { | ||
assign(actions, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
babelHelpers.get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
babelHelpers.classCallCheck(this, ActionsGenerator); | ||
babelHelpers.inherits(ActionsGenerator, _ActionsClass); | ||
babelHelpers.createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
babelHelpers.get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
babelHelpers.inherits(ActionsGenerator, _ActionsClass); | ||
babelHelpers.createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
} | ||
new ActionsGenerator(this); | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
new ActionsGenerator(_this8); | ||
})(); | ||
} else { | ||
assign(actions, ActionsClass); | ||
} | ||
return Object.keys(actions).reduce(function (obj, action) { | ||
@@ -592,3 +600,3 @@ var constant = formatAsConstant(action); | ||
value: function addActions(name, ActionsClass) { | ||
this.actions[name] = this.createActions(ActionsClass); | ||
this.actions[name] = Array.isArray(ActionsClass) ? this.generateActions.apply(this, ActionsClass) : this.createActions(ActionsClass); | ||
} | ||
@@ -595,0 +603,0 @@ }, |
@@ -485,40 +485,48 @@ "use strict"; | ||
var actions = assign({}, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
var actions = {}; | ||
var key = ActionsClass.name || ActionsClass.displayName || ""; | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
_classCallCheck(this, ActionsGenerator); | ||
if (typeof ActionsClass === "function") { | ||
(function () { | ||
assign(actions, getInternalMethods(ActionsClass.prototype, builtInProto)); | ||
_get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
var ActionsGenerator = (function (_ActionsClass) { | ||
function ActionsGenerator(alt) { | ||
_classCallCheck(this, ActionsGenerator); | ||
_inherits(ActionsGenerator, _ActionsClass); | ||
_get(Object.getPrototypeOf(ActionsGenerator.prototype), "constructor", this).call(this, alt); | ||
} | ||
_createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
_inherits(ActionsGenerator, _ActionsClass); | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
_createClass(ActionsGenerator, { | ||
generateActions: { | ||
value: function generateActions() { | ||
for (var _len = arguments.length, actionNames = Array(_len), _key = 0; _key < _len; _key++) { | ||
actionNames[_key] = arguments[_key]; | ||
} | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
actionNames.forEach(function (actionName) { | ||
// This is a function so we can later bind this to ActionCreator | ||
actions[actionName] = function (x) { | ||
for (var _len2 = arguments.length, a = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a[_key2 - 1] = arguments[_key2]; | ||
} | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
this.dispatch(a.length ? [x].concat(a) : x); | ||
}; | ||
}); | ||
} | ||
} | ||
}); | ||
new ActionsGenerator(this); | ||
return ActionsGenerator; | ||
})(ActionsClass); | ||
new ActionsGenerator(_this8); | ||
})(); | ||
} else { | ||
assign(actions, ActionsClass); | ||
} | ||
return Object.keys(actions).reduce(function (obj, action) { | ||
@@ -610,3 +618,3 @@ var constant = formatAsConstant(action); | ||
value: function addActions(name, ActionsClass) { | ||
this.actions[name] = this.createActions(ActionsClass); | ||
this.actions[name] = Array.isArray(ActionsClass) ? this.generateActions.apply(this, ActionsClass) : this.createActions(ActionsClass); | ||
} | ||
@@ -613,0 +621,0 @@ }, |
{ | ||
"name": "alt", | ||
"version": "0.15.2", | ||
"version": "0.15.3", | ||
"description": "A flux implementation", | ||
@@ -5,0 +5,0 @@ "main": "dist/alt.js", |
@@ -59,2 +59,7 @@ import Alt from '../dist/alt-with-runtime' | ||
const objActions = alt.createActions({ | ||
hello() { }, | ||
world() { } | ||
}) | ||
const myShorthandActions = alt.generateActions("actionOne", "actionTwo") | ||
@@ -321,2 +326,3 @@ | ||
this.addActions('myActions', MyActions) | ||
this.addActions('fauxActions', ['one', 'two']) | ||
this.addStore('myStore', MyStore) | ||
@@ -431,2 +437,4 @@ } | ||
assert.isFunction(myShorthandActions.actionTwo, 'other action created with shorthand createActions exists') | ||
assert.isFunction(objActions.hello, 'actions created by obj are functions') | ||
assert.isFunction(objActions.world, 'actions created by obj are functions') | ||
}, | ||
@@ -768,2 +776,5 @@ | ||
const fauxActions = altInstance.getActions('fauxActions') | ||
assert.isFunction(fauxActions.one, 'faux actions were generated') | ||
const myActionsFail = altInstance.getActions('ActionsThatDontExist') | ||
@@ -770,0 +781,0 @@ assert.isUndefined(myActionsFail, 'undefined actions') |
334665
6844