Lobster

public class Lobster

Lobster

Lobster wraps Remote Config’s interface

  • The instance of Lobster.

    Declaration

    Swift

    public static let shared: Lobster
  • The FIRRemoteConfig instance.

    Note

    Basically, You don’t have to use this directly.

    Declaration

    Swift

    public let remoteConfig: RemoteConfig
  • The default expiration duration. 12 hours

    Declaration

    Swift

    public static let defaultExpirationDuration: TimeInterval
  • A fetch expiration duration. You can change it you want.

    Default is defaultExpirationDuration

    Declaration

    Swift

    public var fetchExpirationDuration: TimeInterval
  • A flag indicating whether to check for stale status or not.

    Default is true.

    Declaration

    Swift

    public var useStaleChecker: Bool
  • A value store to store isStaled, which is the flag to judge remote config stale or not.

    You can inject another value store conforming to StaleValueStore protocol. Default is UserDefaults.

    Declaration

    Swift

    public var staleValueStore: StaleValueStore
  • set/get isStaled flag. If useStaleChecker is true and isStaled is true, Lobster fetch remote config values from Firebase immediately ignoring cache expiration when you call Lobster.shared.fetch(completion:)

    Declaration

    Swift

    public var isStaled: Bool { get set }
  • Debug mode NOTE: It must be false on production.

    Declaration

    Swift

    public var debugMode: Bool { get set }
  • Returns RemoteConfigFetchStatus.

    Declaration

    Swift

    public private(set) var fetchStatus: RemoteConfigFetchStatus { get }
  • Default value store.

    Declaration

    Swift

    public let defaultsStore: DefaultsStore
  • Fetches config data from Firebase. If its cache hasn’t expired, RemoteConfig won’t fetch but will return cache data.

    Declaration

    Swift

    public func fetch(completion: @escaping (Error?) -> Void = { _ in })

    Parameters

    completion

    A closure that takes an error as its argument. If Lobster fetched config from Firebase successfully, the argument of error will be nil. Default is an empty closure.

  • Set default config values. By setting default config values, You can use these value safely before fetching config data from Firebase.

    Declaration

    Swift

    public func setDefaults(_ defaults: [String : AnyObject])

    Parameters

    defaults

    A dictionary that will set as default config values

  • Set default values using loaded data from plist

    Declaration

    Swift

    public func setDefaults(fromPlist plistFileName: String, bundle: Bundle = .main)

    Parameters

    plistFileName

    plist file name w/o extension

    bundle

    bundle that embedded plist file. (Default is main bundle)

  • Clear default values and then RemoteConfig’s default values will be updated to empty.

    Declaration

    Swift

    public func clearDefaults()
  • Returns CombineLobster.

    Declaration

    Swift

    var combine: CombineLobster { get }
  • Get value with given config key.

    You can use this subscripting if a type of config key is ConfigKey<T?>. This is, ConfigKey.ValueType must be Optional type such as String?. Also, T is needed to be conformed protocol ConfigSerializable

    Lobster will return the value for key if RemoteConfig has the value at first. If not so, Lobster will try to retrieve value from DefaultsStore automatically. If Neigher RemoteConfig nor DefaultsStore have the value, Lobster will return nil.

    Declaration

    Swift

    subscript<T>(key: ConfigKey<T?>) -> T.Value? where T : ConfigSerializable { get }
  • Get value from remote-config -> default

    Declaration

    Swift

    subscript<T>(key: ConfigKey<T>) -> T.Value where T : ConfigSerializable { get }
  • Get value safely from remote-config -> default

    Declaration

    Swift

    subscript<T>(safe key: ConfigKey<T>) -> T.Value? where T : ConfigSerializable { get }
  • Get value from config

    Declaration

    Swift

    subscript<T>(config key: ConfigKey<T?>) -> T.Value? where T : ConfigSerializable { get }
  • Get value from config

    Declaration

    Swift

    subscript<T>(config key: ConfigKey<T>) -> T.Value where T : ConfigSerializable { get }
  • Get value safely from config

    Declaration

    Swift

    subscript<T>(safeConfig key: ConfigKey<T>) -> T.Value? where T : ConfigSerializable { get }
  • Get value from default / Set value to default

    Declaration

    Swift

    subscript<T>(default key: ConfigKey<T?>) -> T.Value? where T : ConfigSerializable { get set }
  • Get value from default / Set value to default

    If DefaultsStore doesn’t have a value matched a config key, Lobster will throw a fatal error. If you can get the value safely, please use safeDefault: subscripting instead.

    Declaration

    Swift

    subscript<T>(default key: ConfigKey<T>) -> T.Value where T : ConfigSerializable { get set }
  • Get value safely from default

    If DefaultsStore doesn’t have a value matched a config key, Lobster will return nil.

    Declaration

    Swift

    subscript<T>(safeDefault key: ConfigKey<T>) -> T.Value? where T : ConfigSerializable { get }
  • Get value from remote-config -> default

    Declaration

    Swift

    subscript<T>(key: DecodableConfigKey<T>) -> T.Value where T : ConfigSerializable, T : Decodable { get }
  • Get value safely from remote-config -> default

    Declaration

    Swift

    subscript<T>(safe key: DecodableConfigKey<T>) -> T.Value? where T : ConfigSerializable, T : Decodable { get }
  • Get value from config

    Declaration

    Swift

    subscript<T>(config key: DecodableConfigKey<T?>) -> T.Value? where T : ConfigSerializable, T : Decodable { get }
  • Get value from config

    Declaration

    Swift

    subscript<T>(config key: DecodableConfigKey<T>) -> T.Value where T : ConfigSerializable, T : Decodable { get }
  • Get value safely from config

    Declaration

    Swift

    subscript<T>(safeConfig key: DecodableConfigKey<T>) -> T.Value? where T : ConfigSerializable, T : Decodable { get }
  • Get value from remote-config -> default

    Declaration

    Swift

    subscript<T>(key: CodableConfigKey<T>) -> T.Value where T : ConfigSerializable, T : Decodable, T : Encodable { get }
  • Get value safely from remote-config -> default

    Declaration

    Swift

    subscript<T>(safe key: CodableConfigKey<T>) -> T.Value? where T : ConfigSerializable, T : Decodable, T : Encodable { get }
  • Get value from config

    Declaration

    Swift

    subscript<T>(config key: CodableConfigKey<T?>) -> T.Value? where T : ConfigSerializable, T : Decodable, T : Encodable { get }
  • Get value from config

    Declaration

    Swift

    subscript<T>(config key: CodableConfigKey<T>) -> T.Value where T : ConfigSerializable, T : Decodable, T : Encodable { get }
  • Get value safely from config

    Declaration

    Swift

    subscript<T>(safeConfig key: CodableConfigKey<T>) -> T.Value? where T : ConfigSerializable, T : Decodable, T : Encodable { get }
  • Get value from default / Set value to default

    Declaration

    Swift

    subscript<T>(default key: CodableConfigKey<T?>) -> T.Value? where T : ConfigSerializable, T : Decodable, T : Encodable { get set }
  • Get value from default / Set value to default

    If DefaultsStore doesn’t have a value matched a config key, Lobster will throw a fatal error. If you can get the value safely, please use safeDefault: subscripting instead.

    Declaration

    Swift

    subscript<T>(default key: CodableConfigKey<T>) -> T.Value where T : ConfigSerializable, T : Decodable, T : Encodable { get set }
  • Get value safely from default

    If DefaultsStore doesn’t have a value matched a config key, Lobster will return nil.

    Declaration

    Swift

    subscript<T>(safeDefault key: CodableConfigKey<T>) -> T.Value? where T : ConfigSerializable, T : Decodable, T : Encodable { get }
  • The key of Notification. Lobster notifies you of finishing fetching config data from Firebase.

    Note

    If an error occurred while fetching data, it’ll be included as the object of Notification.

    Declaration

    Swift

    public static var didFetchConfig: Notification.Name { get }