Created
March 4, 2020 07:24
-
-
Save surajsau/53661659f470a19b7ac1ba87bd9c5547 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
@propertyWrapper | |
struct GET<T: Decodable> { | |
private var url: URL | |
init(url: String) { | |
self.url = URL(string: url)! | |
} | |
var wrappedValue: Observer<T> { | |
get { | |
return { observer in | |
AF.request(self.url).validate() | |
.responseDecodable(of: T.self) { response in | |
observer(response) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment