UNPKG

respond-framework

Version:
31 lines (30 loc) 786 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _trySync = require("../../utils/trySync.js"); const end0 = (state, e) => { if (!e.event.end) return; const res = e.event.end.call(state, state, e); return (0, _trySync.default)(res, r => end(state, e, r)); }; var _default = exports.default = end0; const end = (state, e, res) => { state.respond.devtools.sendPluginNotification({ type: 'end', returned: res }, e); const meta = { from: e }; if (res?.error && !res.dispatch) { return e.event.error.dispatch(res, meta).then(_ => false); } else if (res?.dispatch) { return res.dispatch({ meta }); } else if (res) { return e.event.data.dispatch(res, meta).then(_ => res); } };