Closed keelerm84 closed 2 years ago
Is there a replacement for LDFlagValueConvertible
?
Yes, you can use LDValue
similarly to LDFlagValueConvertible
in order to represent all values that a flag variation could inhabit.
We have the following protocol that relies on it, not sure how to migrate it
public protocol Feature {
associatedtype Value: LDFlagValueConvertible
static var fallback: Value { get }
static var key: String { get }
}
public extension Feature where Value == Bool {
static var fallback: Value {
false
}
}
etc
We'll have some migration guides published on the docs site shortly that may be helpful. The impression I get from your code sample is that the Feature
protocol is assisting in typing the variation
method, which may be less necessary with the new specifically typed variation methods (e.g. boolVariation
). I'll link the migration guides here when they go live.
Here are the migration guides for Swift and Objective-C.
This code sample in the migration guide linked above looks backwards? 5.x didn't have LDValue
did it? Other samples seem fine.
Indeed you are correct, thanks for pointing out this issue in the migration guide. I've put a fix up internally, so it'll be fixed on the site as soon as it gets through review and release.
Thanks! @gwhelanLD
[6.0.0] - 2022-05-04
This major version has accompanying migration guides for Swift and Objective-C. Please see the guide for more information on updating to this version of the SDK, as the following is just a summary of the changes.
Note that Objective-C bridging types are prefixed by
Objc
, but that prefix is not exposed to code written in Objective-C. For example, changes listed toObjcLDClient
are changes to the class referred to asLDClient
from within Objective-C.Added
LDValue
class to represent any data type that is allowed in JSON. This new type is used to provide more type safety when representing complex or non-statically determined data types. The SDK also provides the bridge typesObjcLDValue
andObjcLDValueType
for Objective-C interoperability.UserAttribute
class which provides a less error-prone way to refer to user attribute names in configuration.boolVariation
,intVariation
,doubleVariation
,stringVariation
, andjsonVariation
, toLDClient
.boolVariationDetail
,intVariationDetail
,doubleVariationDetail
,stringVariationDetail
, andjsonVariationDetail
, toLDClient
.jsonVariation
andjsonVariationDetail
toObjcLDClient
. These functions allow evaluating feature flags where the provideddefaultValue
and the resulting variation can be any valid JSON data type.ObjcLDJSONEvaluationDetail
for retrieving the detailed evaluation information of arbitrary type flag variations.ObjcLDChangedFlagHandler
type alias for new non-type specific Objective-C flag observers.Changed (API)
LDClient.track(key: data: metricValue:)
no longerthrows
.data
parameter ofLDClient.track(key: data: metricValue:)
has changed fromAny?
toLDValue?
.ObjcLDClient.track(key: data:)
andObjcLDClient.track(key: data: metricValue:)
no longerthrows
. In Objective-C this change means that thetrack
functions no longer accept aerror:
parameter.data
parameter ofObjcLDClient.track(key: data:)
andObjcLDClient.track(key: data: metricValue)
has changed fromAny?
toObjLDValue?
. In Objective-C this would be a change fromid _Nullable
toLDValue * _Nullable
.LDClient.allFlags
now has the type[LDFlagKey: LDValue]?
rather than[LDFlagKey: Any]?
.ObjcLDClient.allFlags
now has the type[String: ObjcLDValue]?
rather than[String: Any]?
. In Objective-C this would be a change fromNSDictionary<NSString*, id> * _Nullable
toNSDictionary<NSString*, LDValue*> * _Nullable
.LDUser.custom
dictionary, and the correspondingLDUser.init
parameter has been changed from[String: Any]?
to[String: LDValue]
.ObjcLDUser.custom
property has been changed from[String: Any]?
to[String: ObjcLDValue]
. In Objective-C this would be a change fromNSDictionary<NSString*, id> * _Nullable
toNSDictionary<NSString*, LDValue*> * _Nonnull
.LDUser.privateAttributes
property, and the correspondingLDUser.init
parameter, have been changed from[String]?
to[UserAttribute]
.ObjcLDUser.privateAttributes
property has been changed from[String]?
to[String]
. In Objective-C this would be a change fromNSArray<NSString*> * _Nullable
toNSArray<NSString*> * _Nonnull
.LDChangedFlag.oldValue
andLDChangedFlag.newValue
have been changed fromAny?
toLDValue
.LDConfig.privateUserAttributes
property has been changed from[String]?
to[UserAttribute]
.ObjcLDConfig.privateUserAttributes
now has the non-optional type[String]
rather than[String]?
. In Objective-C this would be a change fromNSArray<NSString*> * _Nullable
toNSArray<NSString*> * _Nonnull
.LDEvaluationDetail.reason
property has been changed from[String: Any]
to[String: LDValue]
.reason
property ofObjcLDBoolEvaluationDetail
,ObjcLDIntegerEvaluationDetail
,ObjcLDDoubleEvaluationDetail
, andObjcLDStringEvaluationDetail
has been changed from[String: Any]?
to[String: ObjcLDValue]?
. In Objective-C this would be a change fromNSDictionary<NSString*, id> * _Nullable
toNSDictionary<NSString*, LDValue*> * _Nullable
.Changed (behavioral)
Equatable
instance forLDUser
has been changed to compare all user properties, rather than just thekey
property."custom"
as a private attribute name inLDConfig.privateUserAttributes
orLDUser.privateAttributes
will no longer set allLDUser
custom attributes private.device
andoperatingSystem
custom attributes can now be set private.Removed
LDClient.variation(forKey: defaultValue:)
andLDClient.variationDetail(forKey: defaultValue:)
functions. Please use the new type-specific variation functions instead (e.g.LDClient.boolVariation(forKey: defaultValue:)
).LDFlagValueConvertible
protocol which was previously used to constrain the parameters and return types of the variation functions.LDErrorHandler
andLDClient.observeError(owner: handler:)
have been removed. Please useConnectionInformation
instead.LDUser.init(userDictionary: )
andObjcLDUser.init(userDictionary: )
initializers, please use the explicit initializers instead.LDUser.CodingKeys
. To refer to user attributes, please useUserAttribute
instead.LDUser.privatizableAttributes
andObjcLDUser.privatizableAttributes
.ObjcLDUser.attributeCustom
.LDUser.device
andLDUser.operatingSystem
properties, and the correspondingLDUser.init
parameters have been removed. These fields will be included in theLDUser.custom
dictionary.ObjcLDUser.device
andObjcLDUser.operatingSystem
properties have been removed. These fields will be included in theObjcLDUser.custom
dictionary.ObjcLDClient
functions,arrayVariation
,arrayVariationDetail
,dictionaryVariation
, anddictionaryVariationDetail
, have been removed. Please useObjcLDClient.jsonVariation
andObjcLDClient.jsonVariationDetail
instead.ObjcLDChangedFlag
have been removed. Please use the base classObjcLDChangedFlag
, which now providesoldValue
andnewValue
ObjcLDValue
properties. The removed classes areObjcLDBoolChangedFlag
,ObjcLDIntegerChangedFlag
,ObjcLDDoubleChangedFlag
,ObjcLDStringChangedFlag
,ObjcLDArrayChangedFlag
, andObjcLDDictionaryChangedFlag
.ObjcLDArrayEvaluationDetail
andObjcLDDictionaryEvaluationDetail
have been removed. Please useObjcLDJSONEvaluationDetail
instead.ObjcLDBoolChangedFlagHandler
,ObjcLDIntegerChangedFlagHandler
,ObjcLDDoubleChangedFlagHandler
,ObjcLDStringChangedFlagHandler
,ObjcLDArrayChangedFlagHandler
, andObjcLDDictionaryChangedFlagHandler
, have been removed. Please useObjcLDChangedFlagHandler
instead.ObjcLDClient
functions,observeBool
,observeInteger
,observeDouble
,observeString
,observeArray
, andobserveDictionary
, have been removed. Please use the non-type specificObjcLDClient.observe(key: owner: handler:)
instead.