From 7027b2772563c0079e4bbd93920c50d078b8a31c Mon Sep 17 00:00:00 2001 From: Adam Campbell Date: Thu, 15 Oct 2020 15:59:34 +1100 Subject: [PATCH] Post previous configuration in the configuration updated notification --- Sources/Afterpay/Afterpay.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/Afterpay/Afterpay.swift b/Sources/Afterpay/Afterpay.swift index 2b834f31..ff8b8906 100644 --- a/Sources/Afterpay/Afterpay.swift +++ b/Sources/Afterpay/Afterpay.swift @@ -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? @@ -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) }