-
Notifications
You must be signed in to change notification settings - Fork 32
feat: add OptimizelyConfig API #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is an opportunity to do some really cool things here. why give access to maps that can go stale? why not instead support subscripting and make it as dynamic and realtime as possible? so instead of optimizely config as an object it is just a set of methods that access the project config (i.e. client.config.features["featureName"] as well as client.config.featureKeys[i]).
I think the main reason you would want it like this is to discourage holding onto potentially stale data.
@@ -16,12 +16,47 @@ | |||
|
|||
import Foundation | |||
|
|||
struct FeatureFlag: Codable, Equatable { | |||
struct FeatureFlag: Codable, Equatable, OptimizelyFeature { | |||
static func == (lhs: FeatureFlag, rhs: FeatureFlag) -> Bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not have these as extensions?
Sources/Data Model/Variable.swift
Outdated
@@ -16,7 +16,35 @@ | |||
|
|||
import Foundation | |||
|
|||
struct Variable: Codable, Equatable { | |||
struct Variable: Codable, Equatable, OptimizelyVariable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this would be cleaner as an extension.
@@ -128,7 +128,7 @@ class DefaultDatafileHandler: OPTDatafileHandler { | |||
completionHandler(result) | |||
|
|||
// avoid event-log-message preparation overheads with closure-logging | |||
self.logger.d({ response.debugDescription }) | |||
//self.logger.d({ response.debugDescription }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we remove this?
/// - Returns: a snapshot of public project configuration data model | ||
/// - Throws: `OptimizelyError` if SDK is not ready | ||
@available(swift, obsoleted: 1.0) | ||
@objc(getOptimizelyConfigWithError:) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this not a property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you're asking if we can use property for "optimizelyConfig" instead of get function. It's a possible option, but we can integrate error throw/return and also in this way, more consistent with other APIs.
Tom, it's an interesting idea to let dynamically access updated data with subscripts. I thought about it but will put aside for now. It'll make sync issue complicated. We need to take a snapshot to provide data consistency. A consistency of API with other SDKs is also considered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - a couple of nits. There is a commented out comment that should probably be removed. Also, it would be great if you could use one of the 27 datafiles we already have for testing instead of adding more. Thanks!
let task = session.uploadTask(with: request, from: event.body) { (_, response, error) in | ||
self.logger.d(response.debugDescription) | ||
let task = session.uploadTask(with: request, from: event.body) { (_, _, error) in | ||
//self.logger.d(response.debugDescription) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
No description provided.