Skip to content

JSContext支持window.setTimeout、window.setInterval

Notifications You must be signed in to change notification settings

BBC6BAE9/TimerForJSContext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

JSContext 支持window.setTimeout

参考1:https://developer.mozilla.org/en-US/docs/Web/API/setTimeout

参考2:https://developer.mozilla.org/en-US/docs/Web/API/setInterval

JavaScript 调用参考

nativeLog("开始计时");
var intervalId = setInterval(function(){nativeLog("客户端完成计时 setInterval 任务");}, 1000);
nativeLog(intervalId);
setTimeout(function(){nativeLog("客户端完成计时任务");clearInterval(intervalId);}, 3000);

Objective - C 参考

JSContext *ctx = [[JSContext alloc] init];
[ctx enableWindowTimer];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"js"];
NSString *script = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[ctx evaluateScript:script];

About

JSContext支持window.setTimeout、window.setInterval

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published