ConfigurationPersisting
public protocol ConfigurationPersisting
Configuration provider protocol used to save data in some specified way implemented in the persistConfiguration(_:) method. Classes that implement this protocol may be passed as a desired outputHandler to a ConfigurationLoader during initialization. When ConfigurationLoader processes its queue and finds configuration data, the data will be passed to the supplied ConfigurationPersisting object’s persistConfiguration(_:) method as the configurationData parameter.
If you choose to receive configuration data in this way, it is up to you to save the data (or not) - it will not be saved or retained by the ConfigurationLoader that supplied the data. By extension, you will also need a method to retrieve data that has been saved using your persistConfiguration(_:) implementation if your app will be utilizing that data later on. An example use case for a class implementing this protocol would be if a developer wishes to encrypt configuration data before writing it to some location, or wishes to write the data to a location other than ConfigurationLoader‘s implementation of this protocol (which is in UserDefaults under ConfigurationProviderUserDefaultsKey).
-
Save data using an alternate method. Data supplied in
configurationby a callingConfigurationLoaderobject will not be retained by thatConfigurationLoader. If reading the data at a later time is required, it is recommended you also implement a mechanism to read data written by this method.Declaration
Swift
func persistConfiguration(_ configuration: [AnyHashable : Any])Parameters
configurationData to be saved.
-
Requests that this class remove any saved data. For example, if your
persistConfiguration(_:)writes the data to some key inUserDefaults, delete that key when this method is called. Called byConfigurationLoader.resetStoredData().Declaration
Swift
func resetPersistedConfiguration()