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
| import SwiftUI | |
| struct SwiftUITextFieldView: UIViewRepresentable { | |
| let textfieldView: CustomUIKitTextFieldView = CustomUIKitTextFieldView() | |
| var viewModel: CustomUIKitTextFieldViewModel | |
| func makeUIView(context: Context) -> CustomUIKitTextFieldView { | |
| textfieldView.viewModel = viewModel | |
| return textfieldView |
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
| <array> | |
| <string>Gilroy-ExtraBold.otf</string> | |
| <string>Gilroy-Light.otf</string> | |
| </array> |
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
| for family in UIFont.familyNames.sorted() { | |
| let names = UIFont.fontNames(forFamilyName: family) | |
| print("Family: \(family) Font names: \(names)") | |
| } |
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
| func preserveClosure(_ externalFunc: @escaping () -> ()) -> () -> () { | |
| var counter = 0 | |
| return { | |
| counter = counter + 1 | |
| externalFunc(counter) | |
| } | |
| } | |
| func externalFunc (counter: Int) { | |
| print("I am called after \(counter)") |
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
| func closureFunc (_ changeValueOf:(Int) -> ()) { | |
| changeValueOf(10) | |
| } | |
| var x = 0 | |
| print(x) | |
| func changeValueOf(newValue: Int) { | |
| x = newValue | |
| } | |
| closureFunc(changeValueOf) |
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
| let behaviorRelay = BehaviorRelay(value: "Initial value") | |
| let disposeBag = DisposeBag() | |
| behaviorRelay.subscribe{ | |
| print(label: "1)", event: $0) | |
| } | |
| .disposed(by: disposeBag) | |
| behaviorRelay.accept("no way") | |
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
| let relay = PublishRelay<String>() | |
| let disposeBag = DisposeBag() | |
| relay.accept("Hello") | |
| relay.subscribe{ | |
| print(label: "1)", event: $0) | |
| } | |
| .disposed(by: disposeBag) | |
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
| let replySubject = ReplaySubject<String>.create(bufferSize: 3) | |
| let disposebag = DisposeBag() | |
| replySubject.onNext("1") | |
| replySubject.onNext("2") | |
| replySubject.onNext("3") | |
| replySubject.onNext("4") | |
| let subscriberOne = replySubject.subscribe{ | |
| print(label: "1)", event: $0) | |
| } |
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
| func print<T: CustomStringConvertible>(label: String, event: Event<T>) { | |
| print(label, (event.element ?? event.error) ?? event ) | |
| } | |
| func() { | |
| let behaviorSubject = BehaviorSubject(value: "Initial behavior") | |
| let disposeBag = DisposeBag() | |
| let subscriberOne = behaviorSubject.subscribe { |
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
| let subject = PublishSubject<String>() | |
| subject.onNext("Hello everyone") | |
| let subscriptionOne = subject.subscribe( | |
| onNext: { msg in | |
| print("msg from sub 1: \(msg)") | |
| } | |
| ) | |
| subject.on(.next("1")) | |
| subject.onNext("2") | |
NewerOlder