CADisplayLink: removeFromRunLoop() method
The removeFromRunLoop() method cancels the CADisplayLink's callbacks for one mode.
Syntax
removeFromRunLoop(runLoop[, { forMode }])Parameters
runLoop
Must be NSRunLoop.mainRunLoop.
options.forMode
One of 'default', 'common', and 'tracking'; defaults to 'default'. See addToRunLoop() for what they mean.
Return value
None (undefined).
Exceptions
TypeError
runLoopis notNSRunLoop.mainRunLoop.forModeis not recognized:forMode has no value "idle"; expected one of: ….
Description
- Once every
forModeit was added with has been canceled, it no longer calls back and can be garbage-collected. - Unlike
invalidate(), you can calladdToRunLoop()again after canceling. Not verified in the simulator.
Examples
js
const link = new CADisplayLink();
link.addToRunLoop(NSRunLoop.mainRunLoop, { forMode: 'common' });
link.removeFromRunLoop(NSRunLoop.mainRunLoop, { forMode: 'common' });Effect: tick no longer fires. Not verified in the simulator.
Corresponding iOS API
-[CADisplayLink removeFromRunLoop:forMode:].