简体   繁体   中英

React-native scheduledTimerWithTimeInterval doesn't work if called from javascript

I'm trying to execute a function every second with Objective-c to see if it improve the performance of the application, this is the code .

If I execute the function startTimer from in the init it work and every second runner it's called, if instead I call it from JS it doesn't work. Does someone know how to fix it?

I found the same issue, however, I found this code that works:

int64_t delayInSeconds = 3.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW,   delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
  // Do Something Here
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM