1.0.5 • Published 4 years ago

rn-collie-proxy v1.0.5

Weekly downloads
24
License
-
Repository
-
Last release
4 years ago

支持对同一个方法进行多次拦截,

支持对一个对象的不同方法进行拦截

支持链式调用

intercept方法返回代理对象

next()方法执行最后一次被拦截的方法

代理Function

/**
 * 防止重复点击的过滤器
 */
export default class ClickFilterInterceptor extends BaseInterceptor {
    static _lastClick = 0;

    onHandle(method: MethodEntity) {
        let now = this.getNow();
        if (now - ClickFilterInterceptor._lastClick >= Constants.CLICK_FILTER_TIME) {
            let timer = new Timer(Constants.CLICK_FILTER_TIME, () => {
                ClickFilterInterceptor._lastClick = this.getNow();
                timer.stop();
            });
            timer.start();
            method.invoke();
        } else {
            method.cancel();
        }

    }

    getNow() {
        return new Date().getTime();
    }
}


Proxy.createFun(onPress).intercept(null, ...realItp).next(e);

代理Object 拦截navigation对象的navigate方法 proxy等同于被拦截的对象

let proxy = Proxy.createObject(navigation).intercept('navigate', new LoginInterceptor());
proxy.navigate('minePage');//or proxy.next('minePage');
1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago