DSBridge-Android icon indicating copy to clipboard operation
DSBridge-Android copied to clipboard

js异步调用native方法时,同时支持同步返回数据

Open CleverSJX opened this issue 5 years ago • 0 comments

场景

js调用native的一个定时器,同步返回一个定时器id,js在不需要这个定时器的时候可以用这个id让native关闭这个定时器,达到节省资源的目的

        var $t1 =  $('#time1');
        var time1Index = 0;
        var time1 = dsBridge.call("timer",{isOnce:false,time:3},function(res){
            time1Index++;
            $t1.html('第一个定时器执行'+time1Index+'次')
            if(time1Index >= 4){
                dsBridge.call("stopTimer",time1)
            }
        });

CleverSJX avatar Sep 11 '20 06:09 CleverSJX