๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90

๐ŸŽ iOS/RxSwift6

[iOS/RxSwift] RxDataSource - UITableView, UICollectionView RxSwift ์—์„œ DataSource ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค! UIKit ์˜ UITableView, UICollectionView ๋ฅผ ์ด์šฉํ•  ๋•Œ์—๋Š” ๊ฐ ๋ฆฌ์ŠคํŠธ์— ๋Œ€ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด data source ๋ฅผ ์ง€์ •ํ•ด์ค˜์•ผ ํ•˜๋Š”๋ฐ์š”. ๊ธฐ๋ณธ์ ์œผ๋กœ๋Š” data source ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•ด, ๋ฉ”์†Œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค. RxSwift ์™€ RxDataSource ์—์„œ๋Š” data source ๋ฉ”์†Œ๋“œ๋ฅผ ์ง์ ‘ ๊ตฌํ˜„ํ•˜์ง€ ์•Š๊ณ  ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์˜คํผ๋ ˆ์ดํ„ฐ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. 1. UIKit ์—์„œ data source ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ• 2. RxSwift ์—์„œ data source ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ• 3. RxDataSource ๋ฅผ ์ด์šฉํ•ด data source ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ• 1. UIKit .. 2021. 10. 17.
[iOS] MVVM & RxSwift ์Šคํ„ฐ๋”” W2 - TableView bind items, modelSelected, cell prepareForReuse [iOS] MVVM & RxSwift ์Šคํ„ฐ๋”” W2 - TableView ๋งŒ๋“ค์–ด๋ณด๊ธฐ iamchiwon/RxSwift_In_4_Hours RxSwift, 4์‹œ๊ฐ„ ์•ˆ์— ๋น ๋ฅด๊ฒŒ ์ตํ˜€ ์‹ค๋ฌด์— ์‚ฌ์šฉํ•˜๊ธฐ. Contribute to iamchiwon/RxSwift_In_4_Hours development by creating an account on GitHub. github.com ๊ณฐํŠ€๊น€๋‹˜ ๊ฐ•์˜ ์˜์ƒ์˜.. jellysong.tistory.com ๊ณฐํŠ€๊น€๋‹˜ RxSwift ๊ฐ•์˜ ์ค‘ step1 ์„ MVVM + TableView ๋กœ ๋ฐ”๊ฟ”๋ณธ ์œ„์˜ ํฌ์ŠคํŒ…์—์„œ View Controller ์—์„œ์˜ ๋ฐ์ดํ„ฐ๋ฐ”์ธ๋”ฉ, TableViewCell ์—์„œ ์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ๋ฅผ ๋”ฐ๋กœ ์ •๋ฆฌํ•œ ๊ธ€์ž…๋‹ˆ๋‹ค! 1 ListViewController / 2 Detai.. 2021. 7. 15.
[iOS] MVVM & RxSwift ์Šคํ„ฐ๋”” W2 - TableView ๋งŒ๋“ค์–ด๋ณด๊ธฐ iamchiwon/RxSwift_In_4_Hours RxSwift, 4์‹œ๊ฐ„ ์•ˆ์— ๋น ๋ฅด๊ฒŒ ์ตํ˜€ ์‹ค๋ฌด์— ์‚ฌ์šฉํ•˜๊ธฐ. Contribute to iamchiwon/RxSwift_In_4_Hours development by creating an account on GitHub. github.com ๊ณฐํŠ€๊น€๋‹˜ ๊ฐ•์˜ ์˜์ƒ์˜ ์ฝ”๋“œ๋Š” step1 ~ 4 ๊นŒ์ง€ ์žˆ๋Š”๋ฐ์š”. step1 ์€ JSON ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•˜๋Š” ์ž‘์—…์„ ๋น„๋™๊ธฐ๋กœ ์ฒ˜๋ฆฌํ•˜๊ณ  ์ด๋ฅผ editView ์— ๋„์›Œ์ฃผ๋Š” ๊ฒƒ์ด๊ณ . step2 ๋Š” step1 ๊ณผ ๊ฐ™์€ JSON ํŒŒ์ผ์„ tableView ๋กœ ๋ณด์—ฌ์ฃผ๋Š” ์ฝ”๋“œ์—์š”. ๊ฐ•์˜์—์„œ step2 ๋Š” ํŒจ์Šคํ•˜์…”์„œ ์ด๋ฅผ ์—ฐ์Šตํ•ด๋ดค์Šต๋‹ˆ๋‹น ๐Ÿง ๐Ÿ‘€ MVVM + RxSwift TableView ์˜ˆ์ œ step2 ์™„์„ฑ ์ฝ”๋“œ์—์„œ๋Š” ํƒ€์ด๋จธ์™€ LOAD ๋ฒ„.. 2021. 7. 15.
[iOS] RxSwift - Subject vs Observable ๊ณฐํŠ€๊น€๋‹˜ ๊ฐ•์˜ [3๊ต์‹œ] RxSwift ํ™œ์šฉ๋ฒ”์œ„ ๋„“ํžˆ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค! ๐Ÿ’ก RxSwift - Observable vs Subject Observable ์€ ์–ด๋–ค ๋ฐ์ดํ„ฐ๋ฅผ ๋‚ด๋ณด๋‚ด์•ผํ• ์ง€ ๋ฏธ๋ฆฌ ์ •ํ•ด์ง„ ํ˜•ํƒœ์˜ ์ŠคํŠธ๋ฆผ์ด๋‹ค. create ํ•˜๋Š” ์‹œ์ ๋ถ€ํ„ฐ ๊ฐ’์ด ์ •ํ•ด์ ธ์žˆ๊ณ , ์ค‘๊ฐ„์— ๋ฐ์ดํ„ฐ ๊ฐ’์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†๋‹ค. ๋ฒ„ํŠผ ์กฐ์ž‘์œผ๋กœ ๋ฐ์ดํ„ฐ ๊ฐ’์„ ๋ณ€๊ฒฝํ•ด์•ผํ•˜๋Š” ๋“ฑ์˜ ์ƒํ™ฉ์—์„œ๋Š” Observable ๋Œ€์‹  Subject ๋ฅผ ์ด์šฉํ•˜๋ฉด ๋œ๋‹ค. Subject ๋Š” Observable ์™ธ๋ถ€์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋„ฃ์–ด์ค„ ์ˆ˜๋„ ์žˆ๊ณ , ๊ตฌ๋…ํ•  ์ˆ˜๋„ ์žˆ๋Š” ์–‘๋ฐฉํ–ฅ์„ฑ์„ ๊ฐ€์ง„ ํƒ€์ž…์ด๋‹ค! Subject ๋Š” ์ผ๋ฐ˜ Observable ์ฒ˜๋Ÿผ subscribe ํ•˜์—ฌ event ๋ฅผ ์ „๋‹ฌ๋ฐ›์„ ์ˆ˜ ์žˆ์Œ๊ณผ ๋”๋ถˆ์–ด, Subject ์™ธ๋ถ€์—์„œ onNext, onCompleted,.. 2021. 7. 14.
[iOS] RxSwift - Observables ์ƒ์„ฑ๊ณผ ๊ตฌ๋…, ์ƒ๋ช…์ฃผ๊ธฐ, operator ๐Ÿ’ก ReacitveX - Observable ReactiveX ์—์„œ Observer ๋Š” Observable ์„ subscribe ํ•œ๋‹ค. observer ๋Š” Observable ์ด ๋ฐฉ์ถœํ•˜๋Š” ์•„์ดํ…œ (๋‹จ์ผ ํ˜น์€ ์‹œํ€€์Šค)์— ์‘๋‹ตํ•œ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ๋™์‹œ์„ฑ(concurrency) ์—ฐ์‚ฐ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. Observable ์ด ๊ฐ์ฒด๋ฅผ ๋ฐฉ์ถœํ•  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆด ํ•„์š” ์—†์ด, ๊ฐ์ฒด๊ฐ€ ๋ฐฉ์ถœ๋˜๋ฉด ๊ทธ ์‹œ์ ์„ ๊ฐ์‹œํ•˜๋Š” ๊ด€์ฐฐ์ž๋ฅผ observer ๋‚ด์— ๋‘๊ณ , ๊ทธ๋ฅผ ํ†ตํ•ด ์•Œ๋ฆผ์„ ๋ฐ›๋Š”๋‹ค. โœ”๏ธŽ Observer ์ƒ์„ฑ & ๊ตฌ๋… ๋น„๋™๊ธฐ ๋ชจ๋ธ์—์„œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ํ๋ฆ„๋Œ€๋กœ ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋œ๋‹ค. async method ํ˜ธ์ถœ๋กœ ๊ฒฐ๊ณผ๋ฅผ ๋ฆฌํ„ด๋ฐ›๊ณ , ํ•„์š”ํ•œ ๋™์ž‘์„ ์ฒ˜๋ฆฌํ•˜๋Š” method ๋ฅผ ์ •์˜ํ•œ๋‹ค. * Observer ์˜ ์ผ๋ถ€ Observable ๋กœ ๋น„๋™๊ธฐ ํ˜ธ์ถœ์„ ์ •.. 2021. 7. 11.
[iOS] MVVM & RxSwift ์Šคํ„ฐ๋”” W1 - Observable ์ƒ๋ช…์ฃผ๊ธฐ์™€ ์“ฐ๋ ˆ๋“œ๊ด€๋ฆฌ iamchiwon/RxSwift_In_4_Hours RxSwift, 4์‹œ๊ฐ„ ์•ˆ์— ๋น ๋ฅด๊ฒŒ ์ตํ˜€ ์‹ค๋ฌด์— ์‚ฌ์šฉํ•˜๊ธฐ. Contribute to iamchiwon/RxSwift_In_4_Hours development by creating an account on GitHub. github.com ๊ณฐํŠ€๊น€๋‹˜ ๊ฐ•์˜ ์˜์ƒ์„ ๋ณด๊ณ , ์ •๋ฆฌํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค! [1๊ต์‹œ] RxSwift ๋ฅผ ์ด์šฉํ•œ ๋น„๋™๊ธฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๐Ÿ’ก RxSwift ๋Š” ๋น„๋™๊ธฐ ์ž‘์—…์˜ ๊ฒฐ๊ณผ๋ฅผ Completion closure ๊ฐ€ ์•„๋‹Œ, ํ•จ์ˆ˜์˜ return ๊ฐ’์œผ๋กœ ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•œ ์œ ํ‹ธ๋ฆฌํ‹ฐ ์ค‘ ํ•˜๋‚˜์ด๋‹ค! ๐Ÿ‘€ ๋น„๋™๊ธฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ, RxSwift ๊ฐ€ ์™œ ํ•„์š”ํ• ๊นŒ? ๋„คํŠธ์›Œํฌ ์ž‘์—… ๋“ฑ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๋Š” ๋ฐ ์‹œ๊ฐ„์ด ๊ฑธ๋ฆฌ๋Š” ์ž‘์—…์˜ ๊ฒฝ์šฐ, ๋น„๋™๊ธฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด ํ•„์š”ํ•˜๋‹ค. ๋™๊ธฐ(sync).. 2021. 7. 11.
728x90