Created
June 26, 2016 22:07
-
-
Save cqfd/c45e517a3e787d68179d96e85a5080c8 to your computer and use it in GitHub Desktop.
Broken signal implementation...
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
class SimpleSignal<E> { | |
private let _v: Variable<E> | |
var value: E { return _v.value } | |
private let _disposeBag = DisposeBag() | |
init(initialValue: E, subsequentValues: Observable<E>) { | |
_v = Variable(initialValue) | |
subsequentValues.bindTo(self._v).addDisposableTo(_disposeBag) | |
} | |
func map<R>(selector: E -> R) -> SimpleSignal<R> { | |
return SimpleSignal<R>(initialValue: selector(value), subsequentValues: _v.asObservable().skip(1).map(selector)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment