Make RCTTiming module lazy

Reviewed By: nicklockwood

Differential Revision: D3346796

fbshipit-source-id: e7fa02f47bfca44272857864472c3f8ef59f56e5
This commit is contained in:
Pieter De Baets 2016-05-25 10:28:40 -07:00 committed by Facebook Github Bot 1
parent 1586a32fa7
commit 4b0f0881eb
1 changed files with 21 additions and 22 deletions

View File

@ -66,32 +66,31 @@
RCT_EXPORT_MODULE()
- (instancetype)init
- (void)setBridge:(RCTBridge *)bridge
{
if ((self = [super init])) {
_paused = YES;
_timers = [NSMutableDictionary new];
RCTAssert(!_bridge, @"Should never be initialized twice!");
for (NSString *name in @[UIApplicationWillResignActiveNotification,
UIApplicationDidEnterBackgroundNotification,
UIApplicationWillTerminateNotification]) {
_paused = YES;
_timers = [NSMutableDictionary new];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(stopTimers)
name:name
object:nil];
}
for (NSString *name in @[UIApplicationDidBecomeActiveNotification,
UIApplicationWillEnterForegroundNotification]) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(startTimers)
name:name
object:nil];
}
for (NSString *name in @[UIApplicationWillResignActiveNotification,
UIApplicationDidEnterBackgroundNotification,
UIApplicationWillTerminateNotification]) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(stopTimers)
name:name
object:nil];
}
return self;
for (NSString *name in @[UIApplicationDidBecomeActiveNotification,
UIApplicationWillEnterForegroundNotification]) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(startTimers)
name:name
object:nil];
}
_bridge = bridge;
}
- (void)dealloc