ConfigBridge
open class ConfigBridge<T>
A bridge class that connects Lobster and ConfigKey.
Getting a value and setting a value are executed in a class that inherit this class.
That is, There are bridge classes that inherit ConfigBridge<T>
for each value type like String
, Int
, etc…
Lobster provides these bridge classes:
- String:
ConfigStringBridge
- Int:
ConfigIntBridge
- Double:
ConfigDoubleBridge
- Float:
ConfigFloatBridge
- Bool:
ConfigBoolBridge
- Data:
ConfigDataBridge
- URL:
ConfigURLBridge
- UIColor:
ConfigColorBridge
- RawRepresentable(Enum):
ConfigRawRepresentableBridge
- Decodable:
ConfigDecodableBridge
- Encodable:
ConfigCodableBridge
- Array:
ConfigArrayBridge
Array for Enum:
ConfigRawRepresentableArrayBridge
Note
It’s an abstract class. If you want to adapt it to some value type, please override it.
-
Initializer
Declaration
Swift
public init()
-
Saves a value to DefaultsStore.
Note
If you create a bridge class by inheritingConfigBridge<T>
, You need to override this function absolutely.Declaration
Swift
open func save(key: String, value: T?, defaultsStore: DefaultsStore)
-
Get a value from RemoteConfig
If a value matched a key doesn’t exist in RemoteConfig , this function will return
nil
Note
If you create a bridge class by inheriting
ConfigBridge<T>
, You need to override this function absolutely.Declaration
Swift
open func get(key: String, remoteConfig: RemoteConfig) -> T?
Return Value
A value of type of T?
-
Get a value from DefaultsStore
If a value matched a key doesn’t exist in DefaultsStore, this function will return
nil
Note
If you create a bridge class by inheriting
ConfigBridge<T>
, You need to override this function absolutely.Declaration
Swift
open func get(key: String, defaultsStore: DefaultsStore) -> T?
Return Value
A value of type of T?
-
Saves a value to DefaultsStore.
Note
If you create a bridge class by inheritingConfigBridge<T>
, You need to override this function absolutely.Declaration
Swift
open func save(key: String, value: T?, defaultsStore: DefaultsStore, encoder: JSONEncoder)
-
Get a value from RemoteConfig
If a value matched a key doesn’t exist in RemoteConfig , this function will return
nil
Note
If you create a bridge class by inheriting
ConfigBridge<T>
, You need to override this function absolutely.Declaration
Swift
open func get(key: String, remoteConfig: RemoteConfig, decoder: JSONDecoder) -> T?
Return Value
A value of type of T?
-
Get a value from DefaultsStore
If a value matched a key doesn’t exist in DefaultsStore, this function will return
nil
Note
If you create a bridge class by inheriting
ConfigBridge<T>
, You need to override this function absolutely.Declaration
Swift
open func get(key: String, defaultsStore: DefaultsStore, decoder: JSONDecoder) -> T?
Return Value
A value of type of T?