rxswift
-
RxAlamofireSwift/RxSwift 2022. 10. 3. 00:01
https://github.com/RxSwiftCommunity/RxAlamofire 책을 뒤져보다가 우연히 RxAlamofire 를 발견했다. (RxCommunity 프로젝트들 중 하나.) Alamofire 는 iOS 진영에서 매우매우 많이 쓰는 API Request Framework 이다. RxAlamofire 를 이용해 쓸 수 있는 단순한 형태의 함수들은 아래와 같은 것들이 있다. // retrieve a request result as raw text RxAlamofire.string(method: HTTPMethod, url: URLConvertible) // decoded json 을 return 하기 때문에, .map 을 이용해서 Type 을 바꿔주거나, // 또는 subscription 내..
-
RxSwift Observable, Subjects and RelaysSwift/RxSwift 2022. 10. 1. 23:57
Subject Observable 이면서 observer 일 수 있음. (== 데이터를 방출 (emit), 구독 (subscribe) 할 수 있음. ) PublishSubject: empty 로 시작해서 subscribers 에게만 새로운 elements 를 emit BehaviorSubject: 초기값을 가짐. 초기 값 또는 가장 최근 element 를 new subscribers 에게 emit 해줌(replay) ReplaySubject: buffer size 만큼 초기화 되고, 해당 size 만큼의 element 를 지니고 있다가 new subscribers 에게 emit AsyncSubject: subject 가 complete event 를 받을 때만 가장 마지막 next event 값을 emi..
-
UITableView (with RxSwift)Swift/RxSwift 2022. 9. 30. 23:59
TableView 를 RxSwift 로 그리기! CollectionView 도 같은 방식으로 작동한다고 한다. (직접 해봐야 하지만.) 기존의 길고 긴 TableView boilier plate code 대신, cities.bind(to: tableView.rx.items) { (tableView: UITableView, index: Int, element: String) in let cell = UITableViewCell(style: .default, reuseIdentifier: "cell") cell.textLabel?.text = element return cell } 한 다섯줄의 간단한 코드로 기본적인 UITableView 를 만들 수 있다! 작동하는 기본적인 방식은, Observable 을 ..
-
ObservablesSwift/RxSwift 2022. 3. 25. 18:12
Observable == Observable sequence == Sequence An Observable is just a sequence, with some special powers. - Asynchronous. Observables produce events over a period of time, which is referred to as emitting. Events can contain values, such as numbers or instances of a custom type, or they can be recognized by gestures, such as taps. When an observable emits an element, it does so in what’s known a..
-
SubjectsSwift/RxSwift 2022. 3. 25. 00:44
import UIKit import RxSwift func example(of description: String, action: () -> Void) { print("\n--- Example of:", description, "---") action() } Observables are a fundamental part of RxSwift, but they’re essentially read-only. You may only subscribe to them to get notified of new events they produce. A common need when developing apps is to manually add new values onto an observable during runti..
-
Rx Swift Cocoa pods 로 설치하기, playground 연습 환경 구축Swift/Tips & Tricks 2022. 3. 23. 00:08
설치하기 !!! 1. Cocoapods 를 설치한다. (Terminal 에 입력) sudo gem install cocoapods 2. Current Folder 로 이동한다. 3. pod init -> podfile 이 생성된다. pod init 4. podfile 로 들어가서 수정 후 저장, 닫는다. # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'RxSwiftProj' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! # Pods for RxSwiftProj po..