目录

ElementaryCombine

Elementary uni-directional architecture extension. This package provides ObservableStore which can be easily used in SwiftUI apps (but not exclusively).

Installation

When using Swift package manager install using Xcode 11+ or add following line to your dependencies:

.package(url: "https://github.com/mkj-is/ElementaryCombine.git", from: "0.1.0")

Usage

The ObservableStore builds on top of Elementary Store and adds conformance to ObservableObject in Combine. Due to this fact it can ve easily connected to SwiftUI views. See the following example of incrementing counter:

struct RootView: View {
    @ObservedObject var store = ObservableStore(state: 0, update: updateCounter)

    var body: some View {
        VStack {
            Text("\(store.state)")
            Button(action: { self.store.dispatch(.increment) }) {
                Text("Increment")
            }
        }
    }
}

Contributing

All contributions are welcome.

Project was created by Matěj Kašpar Jirásek.

Project is licensed under MIT license.

关于
50.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号