You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 22, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
-64Lines changed: 0 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,70 +23,6 @@ Additionaly **DecideTesting** provides tools to replace the environment and trac
23
23
24
24
## Dependency Injection
25
25
26
-
27
-
# Decide
28
-
29
-
Decide designed to manage state and side-effects, specifically tailored for Swift developers. It is compatible with SwiftUI, but it goes a step further by extending state management beyond the SwiftUI view context.
30
-
31
-
The library addresses some of the limitations found [in SwiftUI's `@State` and `Binding`](https://developer.apple.com/documentation/swiftui/binding) and [Combine's @Published](https://developer.apple.com/documentation/combine/published/) approach, providing a solution for defining state outside of a SwiftUI view, a feature that is currently lacking in SwiftUI.
32
-
33
-
Moreover, "Decide" offers a solution for unidirectional state updates and side-effect management, another area where SwiftUI falls short. Importantly, the library is not limited to SwiftUI and can be used in any non-SwiftUI code.
34
-
35
-
## Key Features
36
-
37
-
-**SwiftUI Compatibility:** Decide is designed to seamlessly integrate with SwiftUI, enhancing its state management capabilities beyond the SwiftUI view context.
38
-
39
-
-**State Declaration:** This feature decouples state declarations from view contexts, providing a way to declare them independently. Unlike `@Published` or `@State`, it doesn't require an instance of the ViewModel or View. Instead, it uses environment and KeyPaths to access the value.
40
-
- It offers `AtomicState` or `KeyedState` classes for group ability and `@Property` to define the name, type, and default value of the state, which is an extended version of SwiftUI's `@State`.
41
-
- It supports both mutable and immutable properties.
42
-
- It introduces `Computation`, a type of state that is computed based on other states and is recomputed when one or more of them change.
43
-
- Keyed States allow for the creation of atomic states that can differentiate based on a `Key`. This is ideal for lists or collections of items that are identical but differentiated by ID or any other key.
44
-
45
-
## How to Use
46
-
47
-
### Declaring State
48
-
49
-
Decide introduces `@Property` as a way to describe the atomic observable value in the environment. This is similar to SwiftUI's `@State`, but it allows for a more atomic standalone state definition:
You can nest state declarations to better define your state by creating a new state within another one or extending it. This doesn't have any effect other than a name change. So, if you decide to restructure your state later, you only need to move properties where they belong and update keypaths that have been used.
72
-
73
-
### Keyed State
74
-
75
-
`KeyedState` is an enhancement for cases where the state is atomic but differentiates depending on a `Key`, such as a list of products, each with its own unique ID. This state is accessed like a dictionary:
76
-
77
-
```swift
78
-
79
-
@Bind(\TodoList.FeatureFlag.$isEnabled) var isFeatureEnabled
80
-
81
-
var body: some View {
82
-
if isFeatureEnabled[myFeatureName] {
83
-
...
84
-
}
85
-
}
86
-
87
-
```
88
-
89
-
90
26
# Decide Testing
91
27
- a library that makes testing of Decide-based code easier by providing convenient syntax sugar.
0 commit comments