Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alt

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alt - npm Package Compare versions

Comparing version 0.16.6 to 0.16.7

flux-build.min.js

16

CHANGELOG.md
# Changelog
## 0.16.7
### Added
* interceptResponse method to data sources [commit](https://github.com/goatslacker/alt/commit/6f074)
### Fixes
* Revert breaking change back to merge state. 0.17.0 will include bootstrap, recycle, and flush replace state instead of merge state. [commit](https://github.com/goatslacker/alt/commit/9bc87)
### Changed
* local method in data source must return null or undefined to trigger remote [commit](https://github.com/goatslacker/alt/commit/4152c)
## 0.16.6

@@ -7,3 +21,3 @@

* Fixes bug with recycle for keys that weren't set at the beginning. [commit](https://github.com/goatslacker/alt/commit/31f8da1b)
* Fixes bug with recycle for keys that weren't set at the beginning. [commit](https://github.com/goatslacker/alt/commit/1f8da1)
* Fixes isLoading for multiple async calls. [commit](https://github.com/goatslacker/alt/commit/6e4ed23)

@@ -10,0 +24,0 @@

27

dist/alt.js

@@ -984,3 +984,6 @@ (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 value = spec.local && spec.local.apply(spec, [state].concat(args));
var shouldFetch = spec.shouldFetch ? spec.shouldFetch.apply(spec, [state].concat(args)) : !value;
var shouldFetch = spec.shouldFetch ? spec.shouldFetch.apply(spec, [state].concat(args)) : value == null;
var intercept = spec.interceptResponse || function (x) {
return x;
};

@@ -991,9 +994,9 @@ // if we don't have it in cache then fetch it

/* istanbul ignore else */
if (spec.loading) spec.loading();
if (spec.loading) spec.loading(intercept(null, spec.loading, args));
spec.remote.apply(spec, [state].concat(args)).then(function (v) {
loadCounter -= 1;
spec.success(v);
spec.success(intercept(v, spec.success, args));
})['catch'](function (v) {
loadCounter -= 1;
spec.error(v);
spec.error(intercept(v, spec.error, args));
});

@@ -1431,13 +1434,9 @@ } else {

if (store) {
(function () {
var config = store.StoreModel.config;
var config = store.StoreModel.config;
var state = store[Sym.STATE_CONTAINER];
if (config.onDeserialize) obj[key] = config.onDeserialize(value) || value;
fn.eachObject(function (k) {
return delete state[k];
}, [state]);
fn.assign(state, obj[key]);
onStore(store);
})();
if (config.onDeserialize) {
obj[key] = config.onDeserialize(value) || value;
}
fn.assign(store[Sym.STATE_CONTAINER], obj[key]);
onStore(store);
}

@@ -1444,0 +1443,0 @@ }, [obj]);

@@ -48,3 +48,3 @@ ---

You then tie this to a store using the `exportAsync` function in the constructor.
You then tie this to a store using the `registerAsync` function in the constructor.

@@ -89,3 +89,3 @@ ```js

This function is called whenever we need to fetch a value remotely. This is determined if `local` returns a falsy value.
This function is called whenever we need to fetch a value remotely. `remote` is only called if `local` returns null or undefined as its value, or if `shouldFetch` returns true.

@@ -105,2 +105,12 @@ Any arguments passed to your public method will be passed through to both local and remote:

### interceptResponse(response, action, args)
This function overrides the value passed to the action. Response is the value returned from the promise in `remote` or `local` and null in the case of loading action, action is the action to be called, args are the arguments (as an array) passed to the data source method.
```js
interceptResponse(data, action, args) {
return 12; // always returns 12 to loading/success/failed
}
```
### loading

@@ -107,0 +117,0 @@

(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){
require('./')
},{"./":3}],2:[function(require,module,exports){
'use strict';

@@ -76,3 +73,3 @@

module.exports = exports['default'];
},{"../utils/AltUtils":7}],3:[function(require,module,exports){
},{"../utils/AltUtils":6}],2:[function(require,module,exports){
'use strict';

@@ -85,5 +82,3 @@

var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { desc = parent = getter = undefined; _again = false; var object = _x3,
property = _x4,
receiver = _x5; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(_x3, _x4, _x5) { var _again = true; _function: while (_again) { var object = _x3, property = _x4, receiver = _x5; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x3 = parent; _x4 = property; _x5 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };

@@ -202,3 +197,3 @@ var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

value: function createAction(name, implementation, obj) {
return _actions2['default'](this, 'global', name, implementation, obj);
return (0, _actions2['default'])(this, 'global', name, implementation, obj);
}

@@ -208,4 +203,2 @@ }, {

value: function createActions(ActionsClass) {
var _this2 = this;
for (var _len4 = arguments.length, argsForConstructor = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {

@@ -215,2 +208,4 @@ argsForConstructor[_key4 - 2] = arguments[_key4];

var _this = this;
var exportObj = arguments[1] === undefined ? {} : arguments[1];

@@ -268,3 +263,3 @@

// create the action
exportObj[actionName] = _actions2['default'](_this2, key, actionName, action, exportObj);
exportObj[actionName] = (0, _actions2['default'])(_this, key, actionName, action, exportObj);

@@ -292,3 +287,3 @@ // generate a constant

StateFunctions.setAppState(this, this.serialize(this._lastSnapshot), function (storeInst) {
storeInst.lifecycle.rollback.push();
storeInst.lifecycle('rollback');
storeInst.emitChange();

@@ -307,3 +302,3 @@ });

StateFunctions.setAppState(this, this.serialize(initialSnapshot), function (storeInst) {
storeInst.lifecycle.init.push();
storeInst.lifecycle('init');
storeInst.emitChange();

@@ -323,3 +318,3 @@ });

StateFunctions.setAppState(this, data, function (storeInst) {
storeInst.lifecycle.bootstrap.push();
storeInst.lifecycle('bootstrap');
storeInst.emitChange();

@@ -376,3 +371,3 @@ });

module.exports = exports['default'];
},{"../utils/functions":13,"./actions":2,"./store":6,"./utils/AltUtils":7,"./utils/StateFunctions":8,"flux":9}],4:[function(require,module,exports){
},{"../utils/functions":12,"./actions":1,"./store":5,"./utils/AltUtils":6,"./utils/StateFunctions":7,"flux":8}],3:[function(require,module,exports){
'use strict';

@@ -406,7 +401,10 @@

this.transmitter = _transmitter2['default']();
this.lifecycle = model.lifecycleEvents;
var lifecycleEvents = model.lifecycleEvents;
this.transmitter = (0, _transmitter2['default'])();
this.lifecycle = function (event, x) {
if (lifecycleEvents[event]) lifecycleEvents[event].push(x);
};
this.state = state || model;
this._storeName = model._storeName;
this.displayName = model.displayName;
this.boundListeners = model.boundListeners;

@@ -419,3 +417,3 @@ this.StoreModel = StoreModel;

this.dispatchToken = alt.dispatcher.register(function (payload) {
_this.lifecycle.beforeEach.push({
_this.lifecycle('beforeEach', {
payload: payload,

@@ -432,3 +430,3 @@ state: _this.state

if (model.handlesOwnErrors) {
_this.lifecycle.error.push({
_this.lifecycle('error', {
error: e,

@@ -448,3 +446,3 @@ payload: payload,

_this.lifecycle.afterEach.push({
_this.lifecycle('afterEach', {
payload: payload,

@@ -455,3 +453,3 @@ state: _this.state

this.lifecycle.init.push();
this.lifecycle('init');
}

@@ -469,12 +467,14 @@

var _transmitter$subscribe = this.transmitter.subscribe(cb);
var dispose = _transmitter$subscribe.dispose;
this.transmitter.subscribe(cb);
return function () {
_this2.lifecycle.unlisten.push();
dispose();
return _this2.unlisten(cb);
};
}
}, {
key: 'unlisten',
value: function unlisten(cb) {
this.lifecycle('unlisten');
this.transmitter.unsubscribe(cb);
}
}, {
key: 'getState',

@@ -491,3 +491,3 @@ value: function getState() {

module.exports = exports['default'];
},{"../../utils/functions":13,"transmitter":12}],5:[function(require,module,exports){
},{"../../utils/functions":12,"transmitter":11}],4:[function(require,module,exports){
'use strict';

@@ -501,2 +501,8 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _transmitter = require('transmitter');
var _transmitter2 = _interopRequireDefault(_transmitter);
var _utilsFunctions = require('../../utils/functions');

@@ -528,5 +534,68 @@

exportPublicMethods: function exportPublicMethods(methods) {
exportAsync: function exportAsync(asyncMethods) {
this.registerAsync(asyncMethods);
},
registerAsync: function registerAsync(asyncDef) {
var _this = this;
var loadCounter = 0;
var asyncMethods = fn.isFunction(asyncDef) ? asyncDef(this.alt) : asyncDef;
var toExport = Object.keys(asyncMethods).reduce(function (publicMethods, methodName) {
var desc = asyncMethods[methodName];
var spec = fn.isFunction(desc) ? desc(_this) : desc;
var validHandlers = ['success', 'error', 'loading'];
validHandlers.forEach(function (handler) {
if (spec[handler] && !spec[handler].id) {
throw new Error('' + handler + ' handler must be an action function');
}
});
publicMethods[methodName] = function () {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
var state = _this.getInstance().getState();
var value = spec.local && spec.local.apply(spec, [state].concat(args));
var shouldFetch = spec.shouldFetch ? spec.shouldFetch.apply(spec, [state].concat(args)) : !value;
var intercept = spec.interceptResponse || function (x) {
return x;
};
// if we don't have it in cache then fetch it
if (shouldFetch) {
loadCounter += 1;
/* istanbul ignore else */
if (spec.loading) spec.loading(intercept(null, spec.loading));
spec.remote.apply(spec, [state].concat(args)).then(function (v) {
loadCounter -= 1;
spec.success(intercept(v, spec.success));
})['catch'](function (v) {
loadCounter -= 1;
spec.error(intercept(v, spec.error));
});
} else {
// otherwise emit the change now
_this.emitChange();
}
};
return publicMethods;
}, {});
this.exportPublicMethods(toExport);
this.exportPublicMethods({
isLoading: function isLoading() {
return loadCounter > 0;
}
});
},
exportPublicMethods: function exportPublicMethods(methods) {
var _this2 = this;
fn.eachObject(function (methodName, value) {

@@ -537,3 +606,3 @@ if (!fn.isFunction(value)) {

_this.publicMethods[methodName] = value;
_this2.publicMethods[methodName] = value;
}, [methods]);

@@ -548,3 +617,5 @@ },

if (lifecycleEvent === 'error') this.handlesOwnErrors = true;
return this.lifecycleEvents[lifecycleEvent].subscribe(handler.bind(this));
var bus = this.lifecycleEvents[lifecycleEvent] || (0, _transmitter2['default'])();
this.lifecycleEvents[lifecycleEvent] = bus;
return bus.subscribe(handler.bind(this));
},

@@ -561,3 +632,3 @@

if (handler.length > 1) {
throw new TypeError('Action handler in store ' + this._storeName + ' for ' + ('' + (symbol.id || symbol).toString() + ' was defined with ') + 'two parameters. Only a single parameter is passed through the ' + 'dispatcher, did you mean to pass in an Object instead?');
throw new TypeError('Action handler in store ' + this.displayName + ' for ' + ('' + (symbol.id || symbol).toString() + ' was defined with ') + 'two parameters. Only a single parameter is passed through the ' + 'dispatcher, did you mean to pass in an Object instead?');
}

@@ -572,3 +643,3 @@

bindActions: function bindActions(actions) {
var _this2 = this;
var _this3 = this;

@@ -582,15 +653,15 @@ fn.eachObject(function (action, symbol) {

if (_this2[action] && _this2[assumedEventHandler]) {
if (_this3[action] && _this3[assumedEventHandler]) {
// If you have both action and onAction
throw new ReferenceError('You have multiple action handlers bound to an action: ' + ('' + action + ' and ' + assumedEventHandler));
} else if (_this2[action]) {
} else if (_this3[action]) {
// action
handler = _this2[action];
} else if (_this2[assumedEventHandler]) {
handler = _this3[action];
} else if (_this3[assumedEventHandler]) {
// onAction
handler = _this2[assumedEventHandler];
handler = _this3[assumedEventHandler];
}
if (handler) {
_this2.bindAction(symbol, handler);
_this3.bindAction(symbol, handler);
}

@@ -601,9 +672,9 @@ }, [actions]);

bindListeners: function bindListeners(obj) {
var _this3 = this;
var _this4 = this;
fn.eachObject(function (methodName, symbol) {
var listener = _this3[methodName];
var listener = _this4[methodName];
if (!listener) {
throw new ReferenceError('' + methodName + ' defined but does not exist in ' + _this3._storeName);
throw new ReferenceError('' + methodName + ' defined but does not exist in ' + _this4.displayName);
}

@@ -613,6 +684,6 @@

symbol.forEach(function (action) {
_this3.bindAction(action, listener);
_this4.bindAction(action, listener);
});
} else {
_this3.bindAction(symbol, listener);
_this4.bindAction(symbol, listener);
}

@@ -625,3 +696,3 @@ }, [obj]);

module.exports = exports['default'];
},{"../../utils/functions":13}],6:[function(require,module,exports){
},{"../../utils/functions":12,"transmitter":11}],5:[function(require,module,exports){
'use strict';

@@ -634,5 +705,3 @@

var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { desc = parent = getter = undefined; _again = false; var object = _x,
property = _x2,
receiver = _x3; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };

@@ -690,6 +759,3 @@ exports.createStoreConfig = createStoreConfig;

proto.boundListeners = [];
proto.lifecycleEvents = ['afterEach', 'beforeEach', 'bootstrap', 'error', 'init', 'rollback', 'snapshot', 'unlisten'].reduce(function (obj, name) {
obj[name] = _transmitter2['default']();
return obj;
}, {});
proto.lifecycleEvents = {};
proto.actionListeners = {};

@@ -700,3 +766,3 @@ proto.publicMethods = {};

return fn.assign(proto, _StoreMixin2['default'], {
_storeName: key,
displayName: key,
alt: alt,

@@ -722,32 +788,62 @@ dispatcher: alt.dispatcher

function createStoreFromObject(alt, StoreModel, key) {
var storeInstance = undefined;
function createStoreFromObject(context, model, name) {
var state = model.state;
var bus = (0, _transmitter2['default'])();
var StoreProto = createPrototype({}, alt, key, fn.assign({
getInstance: function getInstance() {
return storeInstance;
},
setState: function setState(nextState) {
doSetState(this, storeInstance, nextState);
var observables = model.observe(context, state);
var signalKeys = keys(observables);
// setup the dependencies and signals
var dependencies = signalKeys.map(function (key) {
return observables[key].dispatchToken;
}).filter(Boolean);
var dispatchToken = context.dispatcher.register(function (payload) {
var action = payload.action;
var data = payload.data;
// bootstrap state
if (action === BOOTSTRAP && data[name]) {
return state = data[name];
}
}, StoreModel));
// bind the store listeners
/* istanbul ignore else */
if (StoreProto.bindListeners) {
_StoreMixin2['default'].bindListeners.call(StoreProto, StoreProto.bindListeners);
}
// pull the signals from the action
var signals = signalKeys.reduce(function (arr, key) {
var value = observables[key];
var list = Array.isArray(value) ? value : [value];
list.forEach(function (observable) {
if (observable === action) arr.push([key, data]);else if (observable.dispatchToken) arr.push([key, observable.get()]);
});
return arr;
}, []);
// bind the lifecycle events
/* istanbul ignore else */
if (StoreProto.lifecycle) {
fn.eachObject(function (eventName, event) {
_StoreMixin2['default'].on.call(StoreProto, eventName, event);
}, [StoreProto.lifecycle]);
}
var emitChange = signals.length;
// create the instance and fn.assign the public methods to the instance
storeInstance = fn.assign(new _AltStore2['default'](alt, StoreProto, StoreProto.state, StoreModel), StoreProto.publicMethods, { displayName: key });
// wait for any derived data
context.dispatcher.waitFor(dependencies);
return storeInstance;
// reduce and output
if (emitChange) {
var nextState = model.reduce(context, state, signals.reduce(function (o, x) {
return (o[x[0]] = x[1], o);
}, {}));
var output = model.output ? model.output(context, state, nextState) : nextState;
state = nextState;
// if no output, no push
if (output !== undefined) bus.push(output);
}
});
var statics = model.statics ? model.statics(context) : {};
return keys(statics).reduce(function (obj, key) {
obj[key] = statics[key];
return obj;
}, {
dispatchToken: dispatchToken,
subscribe: bus.subscribe,
get: function get() {
return state;
}
});
}

@@ -798,7 +894,11 @@

storeInstance = fn.assign(new _AltStore2['default'](alt, store, store[alt.config.stateKey] || store[config.stateKey] || null, StoreModel), utils.getInternalMethods(StoreModel), config.publicMethods, { displayName: key });
if (config.datasource) {
store.exportAsync(config.datasource);
}
storeInstance = fn.assign(new _AltStore2['default'](alt, store, typeof store.state === 'object' ? store.state : null, StoreModel), utils.getInternalMethods(StoreModel), config.publicMethods, { displayName: key });
return storeInstance;
}
},{"../../utils/functions":13,"../utils/AltUtils":7,"./AltStore":4,"./StoreMixin":5,"transmitter":12}],7:[function(require,module,exports){
},{"../../utils/functions":12,"../utils/AltUtils":6,"./AltStore":3,"./StoreMixin":4,"transmitter":11}],6:[function(require,module,exports){
'use strict';

@@ -862,3 +962,3 @@

}
},{}],8:[function(require,module,exports){
},{}],7:[function(require,module,exports){
'use strict';

@@ -885,9 +985,13 @@

if (store) {
var config = store.StoreModel.config;
(function () {
var config = store.StoreModel.config;
if (config.onDeserialize) {
obj[key] = config.onDeserialize(value) || value;
}
fn.assign(store.state, obj[key]);
onStore(store);
var state = store.state;
if (config.onDeserialize) obj[key] = config.onDeserialize(value) || value;
fn.eachObject(function (k) {
return delete state[k];
}, [state]);
fn.assign(state, obj[key]);
onStore(store);
})();
}

@@ -906,3 +1010,3 @@ }, [obj]);

store.lifecycle.snapshot.push();
store.lifecycle('snapshot');
var customSnapshot = config.onSerialize && config.onSerialize(store.state);

@@ -930,3 +1034,3 @@ obj[storeName] = customSnapshot ? customSnapshot : store.getState();

}
},{"../../utils/functions":13}],9:[function(require,module,exports){
},{"../../utils/functions":12}],8:[function(require,module,exports){
/**

@@ -943,3 +1047,3 @@ * Copyright (c) 2014-2015, Facebook, Inc.

},{"./lib/Dispatcher":10}],10:[function(require,module,exports){
},{"./lib/Dispatcher":9}],9:[function(require,module,exports){
/*

@@ -1196,3 +1300,3 @@ * Copyright (c) 2014, Facebook, Inc.

},{"./invariant":11}],11:[function(require,module,exports){
},{"./invariant":10}],10:[function(require,module,exports){
/**

@@ -1252,3 +1356,3 @@ * Copyright (c) 2014, Facebook, Inc.

},{}],12:[function(require,module,exports){
},{}],11:[function(require,module,exports){
"use strict";

@@ -1259,7 +1363,11 @@

var unsubscribe = function unsubscribe(onChange) {
var id = subscriptions.indexOf(onChange);
if (id >= 0) subscriptions.splice(id, 1);
};
var subscribe = function subscribe(onChange) {
subscriptions.push(onChange);
var dispose = function dispose() {
var id = subscriptions.indexOf(onChange);
if (id >= 0) subscriptions.splice(id, 1);
return unsubscribe(onChange);
};

@@ -1275,9 +1383,7 @@ return { dispose: dispose };

return { subscribe: subscribe, push: push };
return { subscribe: subscribe, push: push, unsubscribe: unsubscribe };
}
module.exports = transmitter;
},{}],13:[function(require,module,exports){
},{}],12:[function(require,module,exports){
'use strict';

@@ -1314,2 +1420,5 @@

}
},{}]},{},[1]);
},{}],13:[function(require,module,exports){
require('./')
},{"./":2}]},{},[13]);

@@ -74,3 +74,6 @@ 'use strict';

var value = spec.local && spec.local.apply(spec, [state].concat(args));
var shouldFetch = spec.shouldFetch ? spec.shouldFetch.apply(spec, [state].concat(args)) : !value;
var shouldFetch = spec.shouldFetch ? spec.shouldFetch.apply(spec, [state].concat(args)) : value == null;
var intercept = spec.interceptResponse || function (x) {
return x;
};

@@ -81,9 +84,9 @@ // if we don't have it in cache then fetch it

/* istanbul ignore else */
if (spec.loading) spec.loading();
if (spec.loading) spec.loading(intercept(null, spec.loading, args));
spec.remote.apply(spec, [state].concat(args)).then(function (v) {
loadCounter -= 1;
spec.success(v);
spec.success(intercept(v, spec.success, args));
})['catch'](function (v) {
loadCounter -= 1;
spec.error(v);
spec.error(intercept(v, spec.error, args));
});

@@ -90,0 +93,0 @@ } else {

@@ -26,13 +26,9 @@ 'use strict';

if (store) {
(function () {
var config = store.StoreModel.config;
var config = store.StoreModel.config;
var state = store[Sym.STATE_CONTAINER];
if (config.onDeserialize) obj[key] = config.onDeserialize(value) || value;
fn.eachObject(function (k) {
return delete state[k];
}, [state]);
fn.assign(state, obj[key]);
onStore(store);
})();
if (config.onDeserialize) {
obj[key] = config.onDeserialize(value) || value;
}
fn.assign(store[Sym.STATE_CONTAINER], obj[key]);
onStore(store);
}

@@ -39,0 +35,0 @@ }, [obj]);

{
"name": "alt",
"version": "0.16.6",
"version": "0.16.7",
"description": "A flux implementation",

@@ -5,0 +5,0 @@ "main": "lib",

@@ -129,3 +129,3 @@ # alt

Check out the [API Reference](https://goatslacker.github.io/alt/) for full in-depth docs.
Check out the [API Reference](http://alt.js.org/docs/) for full in-depth docs.

@@ -132,0 +132,0 @@ First we install alt through npm. Although alt is also available through bower.

@@ -63,6 +63,10 @@ import Alt from '../'

remote() {
return new Promise((resolve, reject) => {
setTimeout(() => resolve('TESTTEST'), 200)
})
return Promise.resolve('batman')
},
interceptResponse(x, action, args) {
assert(x === 'batman')
assert(action === StargazerActions.usersReceived)
assert(Array.isArray(args))
return 'TESTTEST'
},
success: StargazerActions.usersReceived,

@@ -69,0 +73,0 @@ error: StargazerActions.failed

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc