Skip to content

Commit

Permalink
Post previous configuration in the configuration updated notification
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjcampbell committed Oct 15, 2020
1 parent f3a37bf commit 7027b27
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/Afterpay/Afterpay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public func setAuthenticationChallengeHandler(_ handler: @escaping Authenticatio
let notificationCenter = NotificationCenter()

extension NSNotification.Name {

/// Fires when the Afterpay configuration is updated with the previous configuration
static let configurationUpdated = NSNotification.Name("ConfigurationUpdated")

}

private var configuration: Configuration?
Expand All @@ -85,7 +88,9 @@ func getConfiguration() -> Configuration? {
/// Sets the Configuration object to use for rendering UI Components in the Afterpay SDK.
/// - Parameter configuration: The configuration or nil to clear.
public func setConfiguration(_ configuration: Configuration?) {
let previousConfiguration = Afterpay.configuration

Afterpay.configuration = configuration

notificationCenter.post(name: .configurationUpdated, object: configuration)
notificationCenter.post(name: .configurationUpdated, object: previousConfiguration)
}

0 comments on commit 7027b27

Please sign in to comment.