Skip to content

Commit d1067d6

Browse files
Add code doc and fix linting issue
1 parent 87bcecf commit d1067d6

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

Sources/Implementation/DefaultDecisionService.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ class DefaultDecisionService: OPTDecisionService {
197197
/// - userProfileTracker: Optional tracker for user profile data.
198198
/// - Returns: A `DecisionResponse` with the variation (if any) and decision reasons.
199199
func getVariation(config: ProjectConfig,
200-
experiment: Experiment,
201-
user: OptimizelyUserContext,
202-
options: [OptimizelyDecideOption]? = nil,
203-
opType: OPType,
204-
userProfileTracker: UserProfileTracker?) -> DecisionResponse<VariationDecision> {
200+
experiment: Experiment,
201+
user: OptimizelyUserContext,
202+
options: [OptimizelyDecideOption]? = nil,
203+
opType: OPType,
204+
userProfileTracker: UserProfileTracker?) -> DecisionResponse<VariationDecision> {
205205
let reasons = DecisionReasons(options: options)
206206
let userId = user.userId
207207
let attributes = user.attributes

Sources/Optimizely+Decide/OptimizelyUserContext.swift

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,31 @@ public class OptimizelyUserContext {
131131
/// - options: Optional array of decision options that will be used for this decision only
132132
/// - completion: A callback that receives the resulting OptimizelyDecision
133133
///
134-
/// - Note: If the SDK is not ready, this method will immediately return an error decision through the completion handler.
134+
/// - Note:
135+
/// - If the SDK is not ready, this method will immediately return an error decision through the completion handler.
136+
/// - The completion handler will be called on a background queue. If you need to update the UI, dispatch to the main queue within the completion handler.
135137
public func decideAsync(key: String,
136-
options: [OptimizelyDecideOption]? = nil,
137-
completion: @escaping DecideCompletion) {
138+
options: [OptimizelyDecideOption]? = nil,
139+
completion: @escaping DecideCompletion) {
138140

139141
guard let optimizely = self.optimizely, let clone = self.clone else {
140142
let decision = OptimizelyDecision.errorDecision(key: key, user: self, error: .sdkNotReady)
141143
completion(decision)
142144
return
143145
}
144146
optimizely.decideAsync(user: clone, key: key, options: options, completion: completion)
145-
146147
}
147148

148149
/// Returns a decision result asynchronously for a given flag key
149150
/// - Parameters:
150151
/// - key: A flag key for which a decision will be made
151152
/// - options: An array of options for decision-making
152153
/// - Returns: A decision result
154+
///
155+
/// - Note: The completion handler will be called on a background queue. If you need to update the UI, dispatch to the main queue within the completion handler.
153156
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
154-
public func decideAsync(key: String,
155-
options: [OptimizelyDecideOption]? = nil) async -> OptimizelyDecision {
157+
public func decideAsync(key: String,
158+
options: [OptimizelyDecideOption]? = nil) async -> OptimizelyDecision {
156159
return await withCheckedContinuation { continuation in
157160
decideAsync(key: key, options: options) { decision in
158161
continuation.resume(returning: decision)
@@ -187,8 +190,9 @@ public class OptimizelyUserContext {
187190
/// - options: An array of options for decision-making.
188191
/// - completion: A callback that receives a dictionary mapping each feature flag key to its corresponding decision result.
189192
///
190-
/// - Note: If the SDK is not ready, this method will immediately return an empty dictionary through the completion handler.
191-
193+
/// - Note:
194+
/// - If the SDK is not ready, this method will immediately return an error decision through the completion handler.
195+
/// - Note: The completion handler will be called on a background queue. If you need to update the UI, dispatch to the main queue within the completion handler.
192196
public func decideAsync(keys: [String],
193197
options: [OptimizelyDecideOption]? = nil,
194198
completion: @escaping DecideForKeysCompletion) {
@@ -207,9 +211,11 @@ public class OptimizelyUserContext {
207211
/// - keys: An array of flag keys for which decisions will be made
208212
/// - options: An array of options for decision-making
209213
/// - Returns: A dictionary of all decision results, mapped by flag keys
214+
///
215+
/// - Note: The completion handler will be called on a background queue. If you need to update the UI, dispatch to the main queue within the completion handler.
210216
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
211-
public func decideAsync(keys: [String],
212-
options: [OptimizelyDecideOption]? = nil) async -> [String: OptimizelyDecision] {
217+
public func decideAsync(keys: [String],
218+
options: [OptimizelyDecideOption]? = nil) async -> [String: OptimizelyDecision] {
213219
return await withCheckedContinuation { continuation in
214220
decideAsync(keys: keys, options: options) { decisions in
215221
continuation.resume(returning: decisions)
@@ -239,7 +245,6 @@ public class OptimizelyUserContext {
239245
/// The closure takes a dictionary of feature/experiment keys to their corresponding decision results.
240246
///
241247
/// - Note: The completion handler will be called on a background queue. If you need to update the UI, dispatch to the main queue within the completion handler.
242-
243248
public func decideAllAsync(options: [OptimizelyDecideOption]? = nil, completion: @escaping DecideForKeysCompletion) {
244249
guard let optimizely = self.optimizely, let clone = self.clone else {
245250
logger.e(OptimizelyError.sdkNotReady)
@@ -253,6 +258,8 @@ public class OptimizelyUserContext {
253258
/// Returns decisions for all active flag keys asynchronously
254259
/// - Parameter options: An array of options for decision-making
255260
/// - Returns: A dictionary of all decision results, mapped by flag keys
261+
///
262+
/// - Note: The completion handler will be called on a background queue. If you need to update the UI, dispatch to the main queue within the completion handler.
256263
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
257264
public func decideAllAsync(options: [OptimizelyDecideOption]? = nil) async -> [String: OptimizelyDecision] {
258265
return await withCheckedContinuation { continuation in

0 commit comments

Comments
 (0)