iOS/Rx 2

[ Rx ] ๊ฒฐํ•ฉ ์—ฐ์‚ฐ - 1. withLatestFrom

withLatestFrom func withLatestFrom(_ second: Source) -> Observable where Source : ObservableConvertibleType Summary ํ•ด๋‹น ์˜ต์ ธ๋ฒ„๋ธ”์ด element๋ฅผ ๋ฐฉ์ถœํ•  ๋•Œ๋งˆ๋‹ค ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์˜ ๊ฐ€์žฅ ์ตœ์‹  element๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‘ ๊ฐœ์˜ ์˜ต์ ธ๋ฒ„๋ธ”์„ ํ•œ ๊ฐœ์˜ ์˜ต์ ธ๋ฒ„๋ธ”๋กœ ๋ณ‘ํ•ฉํ•œ๋‹ค. Discussion Note ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์ด element๋ฅผ ๋ฐฉ์ถœํ•˜๊ธฐ ์ „, ํ•ด๋‹น ์˜ต์ ธ๋ฒ„๋ธ”์ด element๋ฅผ ๋ฐฉ์ถœํ•œ๋‹ค๋ฉด ๊ทธ๊ฑด ๋ˆ„๋ฝ๋  ๊ฒƒ์ด๋‹ค. ์ฆ‰, ์•„๋ฌด๋Ÿฐ ์ž‘์—…๋„ ์ผ์–ด๋‚˜์ง€ ์•Š๋Š”๋‹ค. Parameters ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ๋Š” ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์ด ์˜จ๋‹ค Returns ํ•ด๋‹น ์˜ต์ ธ๋ฒ„๋ธ”์˜ element์™€ ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์˜ ์ตœ์‹  element ๊ฐ๊ฐ์„ ๊ฒฐํ•ฉํ•œ ๊ฒฐ๊ณผ๋ฅผ ํฌํ•จํ•˜๋Š”..

iOS/Rx 2023.10.06

[ iOS/Rx ] 1. RxSwift๋ž€?

๐Ÿงš๐Ÿป‍โ™€๏ธ์š”์•ฝ๐Ÿงš๐Ÿป‍โ™€๏ธ Rx๋Š” Observable ํ˜•ํƒœ๋กœ ํ‘œํ˜„๋˜๋Š” ๋น„๋™๊ธฐ์  ๋ฐ์ดํ„ฐ ํ๋ฆ„์„ ์‚ฌ์šฉํ•œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด๋‹ค. ๊ทธ๊ฒƒ์ด ๊ธฐ๋ฐ˜์ด ๋˜์–ด Swift ์ „์šฉ์œผ๋กœ ๊ตฌํ˜„๋œ ๊ฒƒ์ด ๋ฐ”๋กœ RxSwift์ด๋‹ค. Rx๋Š” ๋น„๋™๊ธฐ์  ์ž‘์—…๊ณผ ๋ฐ์ดํ„ฐ ํ๋ฆ„ ๊ตฌ์„ฑ์„ ์‰ฝ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋ฉฐ ๋ฐ˜์‘ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด์ž ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ์œผ๋กœ ๋˜์–ด์žˆ๋‹ค. ์ „๋‹ฌ๋˜๋Š” ์ด๋ฒคํŠธ์— ๋ฐ”๋กœ ๋ฐ˜์‘ํ•˜์—ฌ ์ž‘์—…์ด ์ด๋ฃจ์–ด์ง„๋‹ค. Reactive ๊ตฌ์„ฑ ์š”์†Œ๋กœ๋Š” Observable(๊ด€์ฐฐ๋Œ€์ƒ), Operator(์—ฐ์‚ฐ์ž), Observer(๊ด€์ฐฐ์ž)๊ฐ€ ์žˆ์œผ๋ฉฐ, ๊ด€์ฐฐ์ž๊ฐ€ ๊ด€์ฐฐ๋Œ€์ƒ์„ ๊ตฌ๋…(Subscribe)ํ•ด์•ผ๋งŒ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. ๋ฐ์ดํ„ฐ ํ๋ฆ„๋“ค์ด ์ด๋ฒคํŠธ์— ๋‹ด๊ฒจ Observable์—์„œ ์‹œ์ž‘ํ•ด Operator์„ ๊ฑฐ์ณ Observer์—๊ฒŒ ๋„๋‹ฌํ•œ๋‹ค. ๋น„๋™๊ธฐ ์ž‘์—… Rx์— ๋Œ€ํ•ด ์•Œ๊ธฐ ์ „ ..

iOS/Rx 2023.06.27
728x90