Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 124fcd4

Browse files
authored
Update README.md
1 parent a34f39d commit 124fcd4

File tree

1 file changed

+0
-64
lines changed

1 file changed

+0
-64
lines changed

README.md

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -23,70 +23,6 @@ Additionaly **DecideTesting** provides tools to replace the environment and trac
2323

2424
## Dependency Injection
2525

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:
50-
51-
```swift
52-
final class TodoList: AtomicState {
53-
54-
// \.TodoList.$networking <- property key path
55-
@DefaultInstance var networking: Networking = URLSession.shared
56-
57-
// \.TodoList.$selectedItemID <- property key path
58-
@Property var selectedItemID: Item.ID?
59-
60-
61-
/// Nested keyed state
62-
final class FeatureFlag: KeyedState<String> {
63-
// \.TodoList.FeatureFlag.$isEnabled <- property key path
64-
// requires access by id e.g. isEnabled[id]
65-
@Property var isEnabled: Bool = false
66-
}
67-
}
68-
```
69-
70-
## Nesting
71-
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-
9026
# Decide Testing
9127
- a library that makes testing of Decide-based code easier by providing convenient syntax sugar.
9228
- [ ] Recursive Override Of Environment

0 commit comments

Comments
 (0)