Skip to content

Commit 2cd2981

Browse files
Add explanation about async behavior
1 parent 771f279 commit 2cd2981

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/Implementation/DefaultDecisionService.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ class DefaultDecisionService: OPTDecisionService {
8484
return DecisionResponse(result: nil, reasons: reasons)
8585
}
8686

87+
// We do not choose the alternative solution (checking and rejecting if on the main thread)
88+
// because it would lead to inconsistent decision results:
89+
// - If the decision is called from the main thread, CMAB logic is skipped and an error is logged.
90+
// - If called from a background thread, CMAB logic is included.
91+
// This means the same API could return different results based on thread context, which is confusing for users.
92+
// Instead, we pass an `isAsync` boolean to ensure that CMAB will be evaluated only for async calls.
93+
8794
guard isAsync else {
8895
let info = LogMessage.cmabNotSupportedInSyncMode
8996
logger.e(info)

0 commit comments

Comments
 (0)