问题标签 [runloop]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - Android:强制主运行循环在当前执行线程完成之前运行
在 iOS 上,如果我希望我当前的执行线程等待(即阻塞)并且主循环运行以便主队列中的下一个执行线程可以执行,我调用:
我将如何在 Android 上做同样的事情?
ios - 在 iOS 主 Runloop 中捕获异常
UIApplication 在主运行循环中捕获异常并重新抛出它,对于 Mac,NSApplication 有一个 reportException: 可以获取 NSException 对象,UIApplication 不提供此方法。是否有类似的东西可以在 iOS 上使用。异常被 UIApplication 捕获并重新抛出它,然后它变成一个 C++ 异常。NSSetUncaughtExceptionHandler 无法捕获它。
关于reportException:,可以参考http://www.cocoabuilder.com/archive/cocoa/7540- catch-exceptions-in-applications.html
ios - 我应该什么时候将 Runloop 应用到我的程序中,为什么?
我的要求是我想每 6 秒调用一次 API 从我的服务器请求一些新信息,所以我编写了如下代码:
但是我今天发现Foundation库提供了一种编写运行循环的方法。所以我可以重写我的代码如下:
但是,我不知道这些是不是比原来的更好的方法来完成我的工作?如果是,为什么?以及如何测试这两种方式之间的效率(或其他属性?)差异?
谢谢!
multithreading - Swift: Async callback in command line utility
I'm trying to fetch data from a website via a command line utility in swift. I'm using NSURLConnection
for this. Like so:
But the application stops running before the callback is called. How do I keep the application running so it won't exit early? I found CFRunLoop()
and have added that in my main file. Now the application doesn't terminate. But I still don't get a response.
The same project in a playground with XCPSetExecutionShouldContinueIndefinitely
does work however. So the problem does not lie in the NSURLConnection code.
ember.js - 为视图的每个 afterRender 计划
我想在每次呈现视图时运行代码。我能得到的最接近的方法是监听每个可能更改的属性,并在运行循环中明确安排某些内容afterRender
,但我希望只有一个生命周期钩子,例如afterRender
. 属性方法变得脆弱,因为您必须根据可能影响渲染的内容来更新属性列表。
控制器:
看法:
模板:
ios - CFRunLoop 如何改变执行顺序
如果我评论CFRunLoopRun();
和CFRunLoopStop(CFRunLoopGetCurrent());
输出:
但如果我不发表CFRunLoopRun();
评论CFRunLoopStop(CFRunLoopGetCurrent());
输出:
我一直认为,如果viewDidLoad
不执行编译,mainQueue
就不会执行新的功能块,但为什么CFRunLoopRun
可以让mainQueue
执行跳过当前功能并执行其他稍后添加的新块asyncQueue
。而何时CFRunLoopStop(CFRunLoopGetCurren))
,viewDidLoad
继续执行。做CFRunLoop
了什么?
ios - 当我们设置 self.navigationItem.hidesBackButton = YES; 时实际调用了什么方法;
我很好奇我们设置时实际调用了什么方法self.navigationItem.hidesBackButton = YES/NO;
。我很好奇,因为该属性不是方法,当我们为任何值分配实际在后台运行的值时,它可以立即隐藏或显示后退按钮。我一直在想有一个运行循环可以不断检查这样的东西。
ios - 如果某个 NSTimer 是使用 scheduleTimerWithTimeInterval 创建的,我如何找出它在哪个运行循环上?
如果我用 scheduleTimerWithTimeInterval 制作了一个 NSTimer,那么根据文档,它应该被添加到当前的运行循环中。我想知道如何检查 NSTimer 在哪个运行循环上。
此外,如果一个计时器无效并创建了一个新计时器,我如何将新计时器添加到第一个计时器所在的同一运行循环中?
提前致谢。
ember.js - 无法弄清楚如何在 Ember 运行循环中包装函数
我有一个集成了 2 个第三方库、imagesLoaded 和 Isotope 的组件。
在浏览器和 cli 模式下运行测试时出现冲突的测试失败。错误是:
Error: Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run
或者
TypeError: 'undefined' is not an object (evaluating 'self.$().isotope')
当我尝试在 ember 运行循环中包装回调时,它们在 cli 模式下传递,但在浏览器模式下失败。我似乎找不到合适的组合。这个问题似乎发生在 imagesLoaded 的回调中,好像我删除了那个插件,它似乎通过了。
我尝试了多种组合,但这是我最新的代码。如果有人对如何正确使用此组件中的运行循环有见解,那将很有帮助。
objective-c - iOS9 NSDefaultRunLoopMode 不听 didRegisterForRemoteNotificationsWithDeviceToken 委托
在 iOS 9 中
不听didRegisterForRemoteNotificationsWithDeviceToken
或didFailToRegisterForRemoteNotificationsWithError
委托,但它听applicationDidEnterBackground
和其他UIApplication
委托。它在 iOS 7 和 iOS 8 上运行良好。
application:didRegisterForRemoteNotificationsWithDeviceToken
总是在 30 秒后调用(超时值)。