Skip to content

Commit ade4c9b

Browse files
committed
[auth-swift] Swift AuthDispatcher, two fakes, one test (#10903)
1 parent 892f8fc commit ade4c9b

File tree

10 files changed

+305
-265
lines changed

10 files changed

+305
-265
lines changed

FirebaseAuth/Sources/Auth/FIRAuth.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#import "FirebaseAuth-Swift.h"
3232
#import "FirebaseAppCheck/Interop/FIRAppCheckInterop.h"
3333
#import "FirebaseAuth/Sources/Auth/FIRAuthDataResult_Internal.h"
34-
#import "FirebaseAuth/Sources/Auth/FIRAuthDispatcher.h"
3534
#import "FirebaseAuth/Sources/Auth/FIRAuthGlobalWorkQueue.h"
3635
#import "FirebaseAuth/Sources/SystemService/FIRAuthStoredUserManager.h"
3736
#import "FirebaseAuth/Sources/User/FIRUser_Internal.h"

FirebaseAuth/Sources/Auth/FIRAuthDispatcher.h

Lines changed: 0 additions & 63 deletions
This file was deleted.

FirebaseAuth/Sources/Auth/FIRAuthDispatcher.m

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import Foundation
16+
17+
// TODO: Get rid of public's and @objc's once FirebaseAuth.m is in Swift.
18+
19+
/** @class AuthDispatcher
20+
@brief A utility class used to facilitate scheduling tasks to be executed in the future.
21+
*/
22+
@objc(FIRAuthDispatcher) public class AuthDispatcher: NSObject {
23+
@objc(sharedInstance) public static let shared = AuthDispatcher()
24+
25+
/** @property dispatchAfterImplementation
26+
@brief Allows custom implementation of dispatchAfterDelay:queue:callback:.
27+
@remarks Set to nil to restore default implementation.
28+
*/
29+
@objc public
30+
var dispatchAfterImplementation: ((TimeInterval, DispatchQueue, @escaping () -> Void) -> Void)?
31+
32+
/** @fn dispatchAfterDelay:queue:callback:
33+
@brief Schedules task in the future after a specified delay.
34+
35+
@param delay The delay in seconds after which the task will be scheduled to execute.
36+
@param queue The dispatch queue on which the task will be submitted.
37+
@param task The task (block) to be scheduled for future execution.
38+
*/
39+
@objc public
40+
func dispatch(afterDelay delay: TimeInterval, queue: DispatchQueue, task: @escaping () -> Void) {
41+
if let dispatchAfterImplementation {
42+
dispatchAfterImplementation(delay, queue, task)
43+
} else {
44+
queue.asyncAfter(deadline: DispatchTime.now() + delay, execute: task)
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)