일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- dismiss
- RxSwift
- NullObject
- swift6
- typeorm
- vim
- Operater
- @Binding
- nestjs
- Creating Operators
- @State
- @Environment
- IOS
- operator
- init
- Xcode
- nonisolated
- graphql
- subject
- RxCocoa
- Operators
- Bug
- URL(string:)
- SwiftUI
- init?
- ios14
- NavigationLink
- SWIFT
- @EnvironmentObject
- RFC1738/1808
- Today
- Total
목록Development/RxSwift (36)
Tunko Development Diary
flatMap flatMap은 하나의 Observable이 발행하는 항목들을 여러개의 Observable로 변환하고, 항목들의 배출을 차례차례 줄 세워 하나의 Observable로 전달한다 let disposeBag = DisposeBag() let numbers = [1,2,3,4,5,6,7,8,9,10] Observable.from(numbers) .flatMap { number -> Observable in switch number { case 1: return Observable.repeatElement("1️⃣").take(3) case 2: return Observable.repeatElement("2️⃣").take(3) case 3: return Observable.repeatElement..
toArray toArray는 옵저버블이 방출하는 모든 이벤트를 완료시점에 배열로 방출합니다. let disposeBag = DisposeBag() let subject = PublishSubject() subject .toArray() .subscribe{ print($0) } .disposed(by: disposeBag) subject.onNext(1) subject.onNext(2) subject.onNext(3) subject.onNext(4) subject.onNext(5) subject.onCompleted() 출력 success([1, 2, 3, 4, 5]) 옵저버블이 Completed가 되지 않으면 아무것도 방출하지 않습니다. map let disposeBag = DisposeBag() l..
debounce let disposeBag = DisposeBag() let tapObservable = Observable.create { observer in DispatchQueue.global().async { for i in 1...10 { observer.onNext("Tap \\(i)") Thread.sleep(forTimeInterval: 0.3) } Thread.sleep(forTimeInterval: 1) for i in 11...20 { observer.onNext("Tap \\(i)") Thread.sleep(forTimeInterval: 0.5) } observer.onCompleted() } return Disposables.create { } } tapObservable .de..
take let disposeBag = DisposeBag() let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Observable.from(numbers) .take(5) .subscribe { print($0) } .disposed(by: disposeBag) 출력 next(1) next(2) next(3) next(4) next(5) completed take 인자로 들어간 count만큼 방출합니다. take(while:) let disposeBag = DisposeBag() let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Observable.from(numbers) .take(while: { $0 < 3} ) .subscribe {..
ignoreElements let disposeBag = DisposeBag() let elements = [0,1,2,3,4,5] Observable.from(elements) .ignoreElements() .subscribe { print($0) } .disposed(by: disposeBag) 옵저버블이 방출하는 Next 이벤트는 무시 error와 completed 이벤트만 받습니다. element(at:) let disposeBag = DisposeBag() let elements = [0,1,2,3,4,5] Observable.from(elements) .element(at: 3) .subscribe { print($0) } .disposed(by: disposeBag) 특정인덱스에 위치한 속..