Comments (4)
Have you tried by having the action type explicit - as in CounterAction.increase(amount: 1) ?
from store.
Thank you for the quick response alex! I followed your suggestion and tried it. It resolved those errors but created new ones:
For reference, here is my full ContentView.swift:
// ContentView.swift
import SwiftUI
import Store
struct Counter { var count = 0 }
enum CounterAction: Action {
case increase(amount: Int)
case decrease(amount: Int)
func reduce(context: TransactionContext<Store<Counter>, Self>) {
defer {
context.fulfill()
}
switch self {
case .increase(let amount):
context.reduceModel { $0.count += amount }
case .decrease(let amount):
context.reduceModel { $0.count -= amount }
}
}
func cancel(context: TransactionContext<Store<Counter>, Self>) { }
}
// MARK: - UI
struct ContentView: View {
@StateObject var store = Store<Counter>(model: Counter())
var body: some View {
// Text("Text without Logic")
Text("counter \(store.model.count)").onTapGesture {
store.run(action: CounterAction.increase(amount: 1))
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().background(Color.gray)
}
}
from store.
Hi! sorry for the late reply :(
This is now fixed in Store 3.6
from store.
@alexdrone No worries, thanks!
from store.
Related Issues (18)
- CocoaPods HOT 1
- Tag problem HOT 5
- type 'CounterAction' does not conform to protocol 'ActionType' HOT 2
- Is it okay to use a class instead of a struct for a store? HOT 3
- Add CI Integration? HOT 1
- Installation Section HOT 7
- Potential race condition in Store.run (?) HOT 1
- Type 'CounterAction' does not conform to protocol 'ActionProtocol' HOT 1
- Combine separate reducers HOT 4
- Handling child stores for lists of data HOT 1
- [Question] Async action with combine HOT 5
- Build failure around RecorderMiddleware+.swift
- Support lower minimal deployment target (current is iOS 10.1) HOT 1
- Compilation error in RecorderMiddleware.swift HOT 5
- Carthage update error (has no shared schemes)
- Build failed with Carthage
- Swift 4 Support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from store.