Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Added NotificationCenter post when keys have finished synchronization #36

Merged
merged 1 commit into from
Apr 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Sources/Zephyr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import UIKit

/// Enumerates the Local (`UserDefaults`) and Remote (`NSUNSUbiquitousKeyValueStore`) data stores
private enum ZephyrDataStore {
Expand All @@ -26,6 +27,9 @@ public final class Zephyr: NSObject {
/// If **true**, then `NSUbiquitousKeyValueStore.synchronize()` will be called immediately after any change is made.
public static var syncUbiquitousKeyValueStoreOnChange = true

/// A string containing the notification name that will be psoted when Zephyr receives updated data from iCloud
public static let keysDidChangeOnCloudNotification = Notification.Name("ZephyrKeysDidChangeOnCloudNotification")

/// The singleton for Zephyr.
private static let shared = Zephyr()

Expand Down Expand Up @@ -435,6 +439,9 @@ extension Zephyr {
for key in monitoredKeys where cloudKeys.contains(key) {
syncSpecificKeys(keys: [key], dataStore: .remote)
}

// Notify any observers that we have finished synchronizing an update from iCloud
NotificationCenter.default.post(name: Zephyr.keysDidChangeOnCloudNotification, object: nil)
}
}

Expand Down