Created
August 19, 2020 22:38
-
-
Save dmytro-anokhin/8485d0b6ea7dac7bec4870210543b9f2 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
final class AnyRemoteContent<Value> : RemoteContent { | |
init<R: RemoteContent>(_ remoteContent: R) where R.ObjectWillChangePublisher == ObjectWillChangePublisher, | |
R.Value == Value { | |
objectWillChangeClosure = { | |
remoteContent.objectWillChange | |
} | |
loadingStateClosure = { | |
remoteContent.loadingState | |
} | |
loadClosure = { | |
remoteContent.load() | |
} | |
cancelClosure = { | |
remoteContent.cancel() | |
} | |
} | |
private let objectWillChangeClosure: () -> ObjectWillChangePublisher | |
var objectWillChange: ObservableObjectPublisher { | |
objectWillChangeClosure() | |
} | |
private let loadingStateClosure: () -> RemoteContentLoadingState<Value> | |
var loadingState: RemoteContentLoadingState<Value> { | |
loadingStateClosure() | |
} | |
private let loadClosure: () -> Void | |
func load() { | |
loadClosure() | |
} | |
private let cancelClosure: () -> Void | |
func cancel() { | |
cancelClosure() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment