UNPKG

@antv/f-engine

Version:

FEngine 是 AntV F 系列可视化引擎的底层渲染引擎,为移动端提供了一套完整的渲染、事件、动画能力,能方便的构建可视化 UI

37 lines (36 loc) 1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = createContext; var _tslib = require("tslib"); function createContext(defaultValue) { // 创建 Context 对象 var context = { _currentValue: defaultValue }; // 定义 Provider 组件 var Provider = function Provider(_a) { var value = _a.value, children = _a.children; context._currentValue = value; return children; }; // Injecter 可以往全局的 context 注入内容 var Injecter = function Injecter(_a, context) { var children = _a.children, props = (0, _tslib.__rest)(_a, ["children"]); Object.assign(context, props); return children; }; Injecter.contextInjecter = context; // 定义 Consumer 组件 var Consumer = function Consumer(_a) { var children = _a.children; return children(context._currentValue); }; context.Provider = Provider; context.Injecter = Injecter; context.Consumer = Consumer; return context; }