@ipp/cli
Version:
An image build orchestrator for the modern web
24 lines (23 loc) • 926 B
JavaScript
;
/**
* Image Processing Pipeline - Copyright (c) Marcus Cemes
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAppStateValue = exports.useAppState = exports.appContext = void 0;
const react_1 = require("react");
const rxjs_1 = require("rxjs");
const rxjs_hooks_1 = require("rxjs-hooks");
const operators_1 = require("rxjs/operators");
exports.appContext = (0, react_1.createContext)(rxjs_1.EMPTY);
function useAppState(map) {
const observable = (0, react_1.useContext)(exports.appContext);
return (0, rxjs_hooks_1.useObservable)(() => map(observable));
}
exports.useAppState = useAppState;
function useAppStateValue(mapper) {
return useAppState((obs) => obs.pipe((0, operators_1.map)(mapper)));
}
exports.useAppStateValue = useAppStateValue;