reshow-flux
Version:
The smallest react flux and Fast hook alternative
39 lines (35 loc) • 991 B
JavaScript
import _objectSpread from "reshow-runtime/es/helpers/objectSpread2";
// @ts-check
import callfunc from "call-func";
/**
* @template StateType
* @template ActionType
* @typedef {import("reshow-flux-base").StoreObject<StateType, ActionType>} StoreObject
*/
/**
* @template StateType
* @template ActionType
* @param {object} props
* @returns{StoreObject<StateType, ActionType>}
*/
var storeLocator = function storeLocator(props) {
return props === null || props === void 0 ? void 0 : props.store;
};
/**
* @returns {object}
*/
var getStore = function getStore(_ref) {
var {
props,
options
} = _ref;
var allProps = _objectSpread(_objectSpread({}, options), props);
var store = callfunc((options === null || options === void 0 ? void 0 : options.storeLocator) || storeLocator, [allProps]);
if (!store) {
console.trace();
throw "Need defined store. such as store={your-store}";
}
allProps.store = store;
return allProps;
};
export default getStore;