ArchitectureVam

0.3.1

insub4067/ArchitectureVam

What's New

0.3.1

2023-10-15T04:36:36Z

🔄 ArchitectureVam

License: MIT Static Badge Static Badge

🤔 What is Vam?

Vam is a package for support MVI (Uni-Directional Architecture) in SwiftUI.

스크린샷 2023-10-15 오후 1 35 16

✔️ View

struct ContentView: VamView {
    
    typealias Action = ContentViewAction
    typealias Model = ContentViewModel
    
    let action: ContentViewAction
    @StateObject var model: ContentViewModel
    
    var body: some View {
        VStack {
            Text("\(model.count)")
            Button("Tap to increase count") {
                action.increaseCount()
            }
        }
    }
    
    static func build() -> ContentView {
        let model = ContentViewModel()
        let action = ContentViewAction(model: model)
        return .init(action: action, model: model)
    }
}

✔️ Action

class ContentViewAction: Action<ContentViewModel> {
    
    func increaseCount() {
        model?.count += 1
    }
}

✔️ Model

class ContentViewModel: Model {
    
    @Published var count = 0
}

Description

  • Swift Tools 5.4.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed May 01 2024 08:58:09 GMT-0900 (Hawaii-Aleutian Daylight Time)