Subscribe to checkForUpdatesCommand's return value.

This commit is contained in:
Cheng Zhao 2014-01-31 21:31:42 +08:00
parent 73ec7783af
commit 8ee1e1d208

View file

@ -37,6 +37,12 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
NSURL* url = [NSURL URLWithString:base::SysUTF8ToNSString(feed)];
NSURLRequest* urlRequest = [NSURLRequest requestWithURL:url];
g_updater = [[SQRLUpdater alloc] initWithUpdateRequest:urlRequest];
}
}
// static
void AutoUpdater::CheckForUpdates() {
RACSignal* signal = [g_updater.checkForUpdatesCommand execute:nil];
AutoUpdaterDelegate* delegate = GetDelegate();
if (!delegate)
@ -44,7 +50,7 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
// Subscribe to events.
__block bool has_update = false;
[g_updater.updates subscribeNext:^(SQRLDownloadedUpdate* downloadedUpdate) {
[signal subscribeNext:^(SQRLDownloadedUpdate* downloadedUpdate) {
has_update = true;
// There is a new update that has been downloaded.
@ -66,11 +72,5 @@ void AutoUpdater::SetFeedURL(const std::string& feed) {
has_update = false;
}];
}
}
// static
void AutoUpdater::CheckForUpdates() {
[g_updater.checkForUpdatesCommand execute:nil];
}
} // namespace auto_updater