Comparing version 0.16.8 to 0.16.9
# Changelog | ||
## 0.16.8 | ||
## 0.16.9 | ||
@@ -25,4 +25,2 @@ ### Added | ||
* Able to return from an action to dispatch rather than calling this.dispatch yourself. [commit](https://github.com/goatslacker/alt/commit/460a749) | ||
## 0.16.7 | ||
@@ -29,0 +27,0 @@ |
@@ -724,6 +724,2 @@ (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 _utilsFunctions = require('../../utils/functions'); | ||
var fn = _interopRequireWildcard(_utilsFunctions); | ||
var _symbolsSymbols = require('../symbols/symbols'); | ||
@@ -746,3 +742,2 @@ | ||
this.alt = alt; | ||
this.dispatched = false; | ||
} | ||
@@ -753,3 +748,2 @@ | ||
value: function dispatch(data) { | ||
this.dispatched = true; | ||
this.alt.dispatch(this[Sym.ACTION_UID], data, this.actionDetails); | ||
@@ -778,8 +772,5 @@ } | ||
var dispatch = function dispatch(payload) { | ||
return alt.dispatch(actionSymbol, payload, data); | ||
}; | ||
// the action itself | ||
var action = function action() { | ||
var action = newAction[Sym.ACTION_HANDLER]; | ||
action.defer = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -789,18 +780,2 @@ args[_key] = arguments[_key]; | ||
newAction.dispatched = false; | ||
var result = newAction[Sym.ACTION_HANDLER].apply(newAction, args); | ||
if (!newAction.dispatched) { | ||
if (fn.isFunction(result)) { | ||
result(dispatch); | ||
} else { | ||
dispatch(result); | ||
} | ||
} | ||
return result; | ||
}; | ||
action.defer = function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
setTimeout(function () { | ||
@@ -823,3 +798,3 @@ newAction[Sym.ACTION_HANDLER].apply(null, args); | ||
},{"../../utils/functions":13,"../symbols/symbols":10,"../utils/AltUtils":11,"es-symbol":1}],7:[function(require,module,exports){ | ||
},{"../symbols/symbols":10,"../utils/AltUtils":11,"es-symbol":1}],7:[function(require,module,exports){ | ||
'use strict'; | ||
@@ -826,0 +801,0 @@ |
@@ -32,13 +32,2 @@ --- | ||
```js | ||
// Calling actions within actions is considered an anti-pattern but at least | ||
// at a quick glance it's easy to tell what updateName is going to fire-off. | ||
MyActions.prototype.updateName = function (name) { | ||
this.dispatch(name); | ||
this.actions.updateFirstName.defer(first(name)); | ||
this.actions.updateLastName.defer(last(name)); | ||
this.actions.saveToDatabase.defer(); | ||
} | ||
``` | ||
## action.CONSTANT | ||
@@ -45,0 +34,0 @@ |
@@ -21,6 +21,2 @@ 'use strict'; | ||
var _utilsFunctions = require('../../utils/functions'); | ||
var fn = _interopRequireWildcard(_utilsFunctions); | ||
var _symbolsSymbols = require('../symbols/symbols'); | ||
@@ -43,3 +39,2 @@ | ||
this.alt = alt; | ||
this.dispatched = false; | ||
} | ||
@@ -50,3 +45,2 @@ | ||
value: function dispatch(data) { | ||
this.dispatched = true; | ||
this.alt.dispatch(this[Sym.ACTION_UID], data, this.actionDetails); | ||
@@ -75,8 +69,5 @@ } | ||
var dispatch = function dispatch(payload) { | ||
return alt.dispatch(actionSymbol, payload, data); | ||
}; | ||
// the action itself | ||
var action = function action() { | ||
var action = newAction[Sym.ACTION_HANDLER]; | ||
action.defer = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
@@ -86,18 +77,2 @@ args[_key] = arguments[_key]; | ||
newAction.dispatched = false; | ||
var result = newAction[Sym.ACTION_HANDLER].apply(newAction, args); | ||
if (!newAction.dispatched) { | ||
if (fn.isFunction(result)) { | ||
result(dispatch); | ||
} else { | ||
dispatch(result); | ||
} | ||
} | ||
return result; | ||
}; | ||
action.defer = function () { | ||
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
setTimeout(function () { | ||
@@ -104,0 +79,0 @@ newAction[Sym.ACTION_HANDLER].apply(null, args); |
{ | ||
"name": "alt", | ||
"version": "0.16.8", | ||
"version": "0.16.9", | ||
"description": "A flux implementation", | ||
@@ -5,0 +5,0 @@ "main": "lib", |
@@ -438,5 +438,7 @@ import Alt from '../' | ||
assert.isFunction(myActions.callInternalMethod, 'shorthand function created with createActions exists') | ||
assert(myActions.callInternalMethod.length === 1, 'shorthand function is an id function') | ||
assert.isFunction(myActions.updateName, 'prototype defined actions exist') | ||
assert.isFunction(myActions.updateTwo, 'prototype defined actions exist') | ||
assert.isFunction(myActions.updateThree, 'prototype defined actions exist') | ||
assert(myActions.updateTwo.length === 2, 'actions can have > 1 arity') | ||
assert.isFunction(myShorthandActions.actionOne, 'action created with shorthand createActions exists') | ||
@@ -443,0 +445,0 @@ assert.isFunction(myShorthandActions.actionTwo, 'other action created with shorthand createActions exists') |
Sorry, the diff of this file is too big to display
567623
122
11745