[[g_updater rac_valuesForKeyPath:@"state" observer:g_updater]
subscribeNext:^(NSNumber *stateNumber) {
int state = [stateNumber integerValue];
- if (state == SQRLUpdaterStateCheckingForUpdate) {
- delegate->OnCheckingForUpdate();
- } else if (state == SQRLUpdaterStateDownloadingUpdate) {
- delegate->OnUpdateAvailable();
- }
+ // Dispatching the event on main thread.
+ dispatch_async(dispatch_get_main_queue(), ^{
+ if (state == SQRLUpdaterStateCheckingForUpdate)
+ delegate->OnCheckingForUpdate();
+ else if (state == SQRLUpdaterStateDownloadingUpdate)
+ delegate->OnUpdateAvailable();
+ });
}];
}
}
delegate->OnError(base::SysNSStringToUTF8(error.localizedDescription));
}];
}
+
} // namespace auto_updater