Created
July 9, 2023 19:12
-
-
Save tornikegomareli/f8ac9e45b9ce5e1ef745907708f58bd1 to your computer and use it in GitHub Desktop.
@escaping example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// Closures-4Jul2023 | |
// | |
// Created by Tornike on 04/07/2023. | |
// | |
import Foundation | |
typealias OnAuthenticateCompletion = ((Bool) -> Void) | |
class MyObservable { | |
private var listeners: [OnAuthenticateCompletion] = [] | |
func registerCallback(listener: @escaping OnAuthenticateCompletion) { | |
listeners.append(listener) | |
} | |
} | |
class UserObject { | |
var myObservable: MyObservable | |
public init(myObservable: MyObservable) { | |
self.myObservable = myObservable | |
} | |
func register() { | |
myObservable.registerCallback(listener: { isSuccess in | |
if isSuccess { | |
print(self.myObservable) | |
} else { | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment