diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:38:48 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 21:53:09 +0800 |
| commit | 26105034da4fcce7ac883c899d781f016559310d (patch) | |
| tree | c459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/vue/src/platforms/weex/util/index.js | |
| parent | 2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff) | |
| download | xmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip | |
switch to vuepress
Diffstat (limited to 'node_modules/vue/src/platforms/weex/util/index.js')
| -rwxr-xr-x | node_modules/vue/src/platforms/weex/util/index.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/node_modules/vue/src/platforms/weex/util/index.js b/node_modules/vue/src/platforms/weex/util/index.js new file mode 100755 index 00000000..8181d70e --- /dev/null +++ b/node_modules/vue/src/platforms/weex/util/index.js @@ -0,0 +1,40 @@ +/* @flow */ +declare var document: WeexDocument; + +import { warn } from 'core/util/index' + +export const RECYCLE_LIST_MARKER = '@inRecycleList' + +// Register the component hook to weex native render engine. +// The hook will be triggered by native, not javascript. +export function registerComponentHook ( + componentId: string, + type: string, // hook type, could be "lifecycle" or "instance" + hook: string, // hook name + fn: Function +) { + if (!document || !document.taskCenter) { + warn(`Can't find available "document" or "taskCenter".`) + return + } + if (typeof document.taskCenter.registerHook === 'function') { + return document.taskCenter.registerHook(componentId, type, hook, fn) + } + warn(`Failed to register component hook "${type}@${hook}#${componentId}".`) +} + +// Updates the state of the component to weex native render engine. +export function updateComponentData ( + componentId: string, + newData: Object | void, + callback?: Function +) { + if (!document || !document.taskCenter) { + warn(`Can't find available "document" or "taskCenter".`) + return + } + if (typeof document.taskCenter.updateData === 'function') { + return document.taskCenter.updateData(componentId, newData, callback) + } + warn(`Failed to update component data (${componentId}).`) +} |
