Version 1.0 Roadmap #42
Replies: 3 comments
-
Hey Maxim, great job drafting a potential version 1 roadmap! Looks great! I really like the direction of using Swift Macros to remove the boilerplate/learning curve from the developer on how to implement their state objects correctly. From what I understand in the current version, we have implementations of Another feedback that I have is around the naming of Let's now talk about the different StateDefinitions. I can see we have almost a permutation of StateDefinitions based if it is These are my thoughts so far, I'll think about the rest as we go. Thank you for kicking off this discussion! |
Beta Was this translation helpful? Give feedback.
-
Hey @serjooo, thank you for the excellent points!
In short, there is a Storage protocol and RW and RO storage protocols to distinguish storages. For example, Computation is a read-only storage, whereas the raw value is a read/write one. This way, the Decision Environment would only support anything that points to storage and provide set-only for RW storages. I have a couple of playgrounds in mind and will share them soon. |
Beta Was this translation helpful? Give feedback.
-
Putting a draft of the API I envision as a version 1.
State definition
To define the state that is managed by
SharedEnvironment
user neds to apply theEnvironmentObservable
root class of the states and then each variable that have a default value. Will be wrapped with required wrappers to enable observability.e.g.
Computed
andInitialValueComputed
are the specicial type of states that has custom calculation using environment.Value Access
to access the value we need macros
@Bind
and@Observe
that take the\Root.observableValue
KeyPath
and expand to a property wrapper that are derived from the type of the value and the root.those macros provide updates to SwiftUI views to cause the rendering. For non SwiftUI objects we need to wrap the object in
@EnvironmentalObject
to have a methodonUpdate
which environment will call when any of@Bind
values change.Roadmap
State Definition
1.1. Atomic Root -> root class for atomic values.
1.2. RootGroup -> a group of atomic roots that environment provides based on ID
1.3. Simple state -> stores the value and provides observability
1.4. Computed state -> computes it's value form environment, invalidated when states used are updated.
1.6. DefaultComputed state -> same as computed but only computes once when initial value is needed.
1.7. GroupedComputed State -> same as computed but takes group id as an additional parameter
1.8. Grouped DefaultComputed State
State Access
2.1. SwiftUI
2.2. Non SwiftUI
State management
3.1. Decision - sync state update.
3.2. Effect - async operation that produces decisions.
Testing
2.1. SwiftUI
2.2. Non SwiftUI
Macros - user must write only what is absolutely necessary.
Persistency - the way to define a strategy, that has access to environment and provided with a key to persist value across sessions.
// stretch
7. Remote Value - the way to define a strategy, that has access to environment and provides the synchronisation. Might require a special type of states that are async.
All this is open to discussion, please share your opinions, and more importantly questions, and suggestions what needs to be included in the roadmap so everyone understands what needs to be done and ready to contribute.
Beta Was this translation helpful? Give feedback.
All reactions