Update activity indicators on leaving room

Signed-off-by: Andy Uhnak <andyuhnak@gmail.com>
This commit is contained in:
Andy Uhnak
2022-02-17 11:10:55 +00:00
parent 1904bd494c
commit 9eae7c02bb
18 changed files with 437 additions and 84 deletions
+12 -4
View File
@@ -26,7 +26,7 @@ import UIKit
/// A client that requests an activity can specify a default timeout after which the activity is dismissed, or it has to be manually
/// responsible for dismissing it via `cancel` method, or by deallocating itself.
public class Activity {
enum State {
public enum State {
case pending
case executing
case completed
@@ -35,7 +35,7 @@ public class Activity {
private let request: ActivityRequest
private let completion: () -> Void
private(set) var state: State
public private(set) var state: State
public init(request: ActivityRequest, completion: @escaping () -> Void) {
self.request = request
@@ -45,7 +45,7 @@ public class Activity {
}
deinit {
cancel()
complete()
}
internal func start() {
@@ -70,7 +70,7 @@ public class Activity {
///
/// Note: clients can call this method directly, if they have access to the `Activity`.
/// Once cancelled, `ActivityCenter` will automatically start the next `Activity` in the queue.
func cancel() {
public func cancel() {
complete()
}
@@ -92,3 +92,11 @@ public extension Activity {
collection.append(self)
}
}
public extension Collection where Element == Activity {
func cancelAll() {
forEach {
$0.cancel()
}
}
}