UNPKG

organism-react-i13n

Version:
76 lines (65 loc) 2.13 kB
import _objectSpread from "reshow-runtime/es/helpers/objectSpread2"; import _classCallCheck from "reshow-runtime/es/helpers/classCallCheck"; import _createClass from "reshow-runtime/es/helpers/createClass"; import _inherits from "reshow-runtime/es/helpers/inherits"; import _createSuper from "reshow-runtime/es/helpers/createSuper"; import get from "get-object-value"; import { ajaxDispatch } from "organism-react-ajax"; import { ImmutableStore, mergeMap } from "reshow-flux"; import { BaseI13nReducer, i13nStoreReAssign } from "i13n"; var getDefaultActionCallback = function getDefaultActionCallback(state) { return function (json, text) { var iframe = get(state.get("iframe")); if (iframe) { iframe.appendHtml(text); } }; }; var I13nStore = /*#__PURE__*/function (_BaseI13nReducer) { _inherits(I13nStore, _BaseI13nReducer); var _super = _createSuper(I13nStore); function I13nStore() { _classCallCheck(this, I13nStore); return _super.apply(this, arguments); } _createClass(I13nStore, [{ key: "sendBeacon", value: function sendBeacon(state, action) { var pvid = state.get("pvid"); var src = state.get("src"); var params = action.params; var query = get(params, ["query"], []); var callback = get(params, ["callback"], function () { // default cb for action return getDefaultActionCallback(state); }); ajaxDispatch({ type: "ajaxPost", params: { url: src + action.type, query: _objectSpread({ pvid: pvid, url: document.URL, params: get(params, ["I13N"]) }, query), callback: callback, disableProgress: true } }); return state; } }]); return I13nStore; }(BaseI13nReducer); var oI13n = new I13nStore(); var _ImmutableStore = ImmutableStore(oI13n.reduce.bind(oI13n)), store = _ImmutableStore[0], i13nDispatch = _ImmutableStore[1]; i13nStoreReAssign({ oI13n: oI13n, store: store, i13nDispatch: i13nDispatch, mergeMap: mergeMap }); export default store; export { i13nDispatch };