UNPKG

@adpt/core

Version:
41 lines 1.31 kB
"use strict"; /* * Copyright 2019 Unbounded Systems, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); const lodash_1 = require("lodash"); function createHookInfo() { return { stateInfo: new Map(), }; } exports.createHookInfo = createHookInfo; const buildContext = []; function startHooks(context) { buildContext.push(context); } exports.startHooks = startHooks; function finishHooks() { buildContext.pop(); } exports.finishHooks = finishHooks; function currentContext() { const ctx = lodash_1.last(buildContext); if (ctx == null) throw new Error(`Hook functions can only be called from an SFC`); return ctx; } exports.currentContext = currentContext; //# sourceMappingURL=hooks.js.map