issues
search
yoogail105
/
KkokkoSwift
꼬리에 꼬리를 무는 swift 개념 정리
28
stars
0
forks
source link
# Data Binding
#58
Open
yoogail105
opened
2 years ago
yoogail105
commented
2 years ago
Data Binding
Data Binding
: 제공자provider와 소비자consumer가 데이터 소스들을 함께 묶어서bind 동기화하는 방식.
묶는다bind
: 제공자가 소비자에게 매번 데이터를 전달하는 것이 아니라, 미리 연결해두고, 데이터가
자동으로 소비자에게 반영되도록
만드는 것!
MVVM에서 Data Binding
MVVM에서 데이터 바인딩을 이용하는 이유는 ViewModel이 View를 몰라서, ViewModel에서 일어난 변화를 View에 전달할 방법이 없기 때문이다.
→ ViewModel이 제공자, View가 소비자가 된다.
→ 데이터를 View의 요소에 연결해 두고(binding), 데이터가 변경될 때마다 View의 UI가 자동으로 업데이트 되도록 한다.
Observing
MVVM에서의 데이터 바인딩의 한 패턴
View는 ViewModel의 데이터가 언제 변하는지 알아야 한다.
→ View는 ViewModel의 데이터를 관찰observing하고 있다가
→ 값이 변하면 Observer에 변경된 값을 알린다.
종류
Property Observer
Closure
KVO(Key-Value Observing)
Notification
Delegate
RxSwift
Combine
🔖 참고
Data Binding in MVVM on iOS
Data Binding
Data Binding
: 제공자provider와 소비자consumer가 데이터 소스들을 함께 묶어서bind 동기화하는 방식.MVVM에서 Data Binding
Observing
종류
🔖 참고