0.0.1-alpha.1 • Published 10 months ago

@kinngyo/wx-refactor v0.0.1-alpha.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

wx-refactor

  • 用于重写 onLoad、onShow 钩子函数

安装

yarn add @kinngyo/wx-refactor

使用

import Refactor from '@kinngyo/wx-refactor'

const refactor = new Refactor()
refactor
    .on('onLoad', callback => {
        /* 这里替代页面hook */
        callback(true, () => {
            /* 页面hook之前执行,前提调用refactor.clear() */
        })
    })
    // 支持链式写法
    .on('onShow', () => {
        // false酒不会延迟到clear执行
        callback(false)
    })
    .done()

注意:一定要在某个时机 clear()方法,否则页面对应 hook 不会触发

Refactor API

属性参数返回说明默认值
RefactorrefactorKey?: stringRefactor定义页面自定义 key'customRefactor'
Refactor.on(hook: RefactorHook, hookCallback?: RefactorHookCallback)Refactor监听 hook
Refactor.done--完成页面监听
Refactor.clear--清空延迟链
0.0.1-alpha.2

10 months ago

0.0.1-alpha.1

10 months ago