Closed alstjr7437 closed 7 months ago
Combine์ ์ ๋ฆฌํ๋ฉด์ ํ๋ก์ ํธ์์ ์งํํ ๋น๋๊ธฐ ๋๊ธฐ ์ฒ๋ฆฌ๋ฅผ ์ด๋ป๊ฒ ํ์ผ๋ฉด ๋์ฑ ๊น๋ํ๊ฒ ์ ๋ฆฌ๊ฐ ๋์์ง ์๊ฐ์ด ๋์.
๋ฐ๋ก ํ๋ก์ ํธ๋ฅผ ๋ณด๋ฉด
SharedData.shared.$userInfo
.sink { [weak self] userInfo in
guard let self = self, !userInfo.isEmpty else { return }
// Handle updated userInfo here
print("main updated userInfo: \(userInfo)")
// Assuming userInfo is an array of strings
self.CautionSource += userInfo[0]
print(CautionSource)
// Reload or update your collection views here
self.cautionView.reloadData()
}
.store(in: &cancellables)
๋ผ๋ ์ฝ๋๊ฐ ์์๋๋ฐ sink๋ฅผ ์ฌ์ฉํ์ง ์๊ณ receive(on:)์ ์ฌ์ฉํ์ผ๋ฉด ๋์ฑ ๊น๋ํ๊ณ ์ข๊ฒ ๋์ ๊ฒ ๊ฐ์.
๐ ๊ณต๋ถ ๋ด์ฉ Combine ๊ฐ๋ ์ดํดํ๊ธฐ
โ ํด์ผํ ์ผ