Skip to content

Commit bc341b3

Browse files
authored
Immediate Async Tasks (#137)
1 parent 8271c53 commit bc341b3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/OAuthKit/OAuth.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ public extension OAuth {
117117
state = .authorizing(provider, grantType)
118118
case .deviceCode:
119119
state = .requestingDeviceCode(provider)
120-
Task(priority: .high) {
120+
Task.immediate {
121121
await requestDeviceCode(provider: provider)
122122
}
123123
case .clientCredentials:
124-
Task(priority: .high) {
124+
Task.immediate {
125125
await requestClientCredentials(provider: provider)
126126
}
127127
case .refreshToken:
128-
Task(priority: .high) {
128+
Task.immediate {
129129
await refreshToken(provider: provider)
130130
}
131131
}
@@ -138,7 +138,7 @@ public extension OAuth {
138138
/// - code: the code to exchange
139139
/// - pkce: the pkce data
140140
func token(provider: Provider, code: String, pkce: PKCE? = nil) {
141-
Task(priority: .high) {
141+
Task.immediate {
142142
await requestToken(provider: provider, code: code, pkce: pkce)
143143
}
144144
}
@@ -242,7 +242,7 @@ private extension OAuth {
242242
if context.canEvaluatePolicy(policy, error: &error) {
243243
context.evaluatePolicy(policy, localizedReason: localizedReason) { [weak self] success, error in
244244
guard let self else { return }
245-
Task(priority: .high) { @MainActor in
245+
Task.immediate { @MainActor in
246246
if success {
247247
self.loadAuthorizations()
248248
}
@@ -309,7 +309,7 @@ private extension OAuth {
309309
tasks.append(task)
310310
} else {
311311
// Execute the task immediately
312-
Task(priority: .high) {
312+
Task.immediate {
313313
await refreshToken(provider: provider)
314314
}
315315
}

0 commit comments

Comments
 (0)