iOS/TCA
-
[TCA] TCA 작동 방식iOS/TCA 2023. 8. 31. 15:04
✅ TCA 작동방식에 대해 정리하고 가자! TCA 구조의 특징 로직이 한 방향으로 흐르기 때문에 각 타입의 역할을 이해하면 side-effect 관리를 쉽게 할 수 있다 역할 State 상태값을 저장하는 객체 Action 사용자의 동작이 일어났을 때 참조하는 객체 Store State, Action, Reducer가 모두 저장되어 있는 Observable 오브젝트 ex) 사용자가 버튼을 클릭하면 -> action에서 reducer로 전달 -> state값 변경 Reducer 들어오는 action을 필터링해서 state 값을 변경할 수 있는 함수 PrimeTime 코드 예시 State struct AppState { var count = 0 var favoritePrimes: [Int] = [] var l..
-
[SwiftUI] 상태관리(Higher-Order Reducers)iOS/TCA 2023. 8. 2. 14:17
PointFree 강의 Composable Architecture Composable State Management: Higher-Order Reducers 정리 📚 이번 강의 목표 Higher-order reducer에 대해 알아보고 적용해보자 Higher-order reducer란? reducer를 input으로 받고, output으로 반환 1. combine 여러 reducer를 input값으로 받고, 각각 주어진 reducer를 실행하여 새로운 reducer를 output으로 반환하는 함수 2. pullback reducer를 input값으로 받고, 로컬 상태와 action에서 작동하는 key path가 주어지면 더 많은 global state와 action에서 작동하는 새로운 reducer를 o..
-
[SwiftUI] 상태관리(Action Pullbacks)iOS/TCA 2023. 7. 18. 00:28
PointFree 강의 Composable Architecture Composable State Management: Action Pullbacks 정리 📚 이번 강의 목표 AppAction을 개별 Action으로 분리해보자 📚 코드 - 기존 코드의 문제점 func counterReducer(state: inout Int, action: AppAction) -> Void { switch action { case .counter(.decrTapped): state -= 1 case .counter(.incrTapped): state += 1 default: break } } counterReducer 함수를 보면 reducer가 정수에서만 작동한다. 하지만 전체 AppAction을 받고 있기 때문에 Cou..
-
[SwiftUI] 상태관리(State Pullbacks)iOS/TCA 2023. 7. 7. 17:44
PointFree 강의 Composable Architecture Composable State Management: State Pullbacks 정리 📚 이번 강의 목표 이전에 작성했던 reducer 코드가 무거워보임 -> 하나의 큰 reducer를 한 가지 특정 작업을 수행하는 여러 개의 reducer로 쪼갠 다음 서로 연결해서 master reducer를 만들어보자 📚 코드 - 기존에 여러 가지 역할을 하는 함수가 정의되어 있는 reducer 코드 func appReducer(value: inout AppState, action: AppAction) -> Void { switch action { case .counter(.decrTapped): state.count -= 1 case .counter..
-
[SwiftUI] 상태관리(redux)iOS/TCA 2023. 7. 6. 17:30
PointFree 강의 Composable Architecture Composable State Management: Reducers 정리 📚 이번 강의 목표 저번 게시글에서 작성한 코드에서 1. Combine으로부터 분리 2. 값 타입의 이점 활용 을 위해 상태 변화를 감지하는 객체를 만들고자 한다! 📚 코드 struct AppState { var count = 0 var favoritePrimes: [Int] = [] var loggedInUser: User? var activityFeed: [Activity] = [] var didChange = PassthroughSubject() struct Activity { let timestamp: Date let type: ActivityType enum..
-
[SwiftUI] 상태 관리iOS/TCA 2023. 7. 5. 10:21
PointFree 강의 Composable Architecture SwiftUI and State Management Part. 1 ~ Part. 3 정리 📚 이번 강의 목표 How to manage state across an entire application How to model the architecture with simple units, such as value types How to modularize each feature of the application How to model side effects in the application How to easily write comprehensive tests for each feature 전체 애플리케이션에서 상태를 관리하는 방법 값 유형과 ..