Skip to content

[ EXPERIMENTAL ] Modular state and side-effects system for your swift application.

License

Notifications You must be signed in to change notification settings

MaximBazarov/Decide

Repository files navigation

Unit Tests


Decide is state and side effect management library. It is compatible with SwiftUI, but also extends state management beyond the SwiftUI view context, and can be used in any non-SwiftUI code. Addresses some of the limitations found in SwiftUI's @State, Binding, and @Published approaches, providing solutions for unidirectional state updates and side-effect management, an area where SwiftUI falls short.

Decide offers a way to define observable states outside of a SwiftUI view and provides a convenient method to separate state updates from the side effects they cause.

This is achieved by introducing the Decision and Effect abstractions, which are designed to define state mutations and execute side effects. These abstractions are more effective for modularization compared to the UseCase/Operation or Action/Reducer/Effect models. They offer a more intuitive approach to business requirements, thereby enhancing the overall coding process. Decide also eliminates the need for dependency injection anywhere but effects and some services and provides tools to define DefaultInstance as a variation of observableState and access it with Instance observableState wrapper to obtain the instance.

Additionaly DecideTesting provides tools to replace the environment and track execution in tests, allowing for the implementation of functionality tests (black box testing) as easily as unit tests.

Decision

Effect

Dependency Injection

Decide Testing

A library that makes testing of Decide-based code easier by providing convenient syntax sugar.

Caveats

  1. Cyclic computations: easy to make a cycle in Computation's dependencies by reading each other.

can be solved by static analysis tools.

About

[ EXPERIMENTAL ] Modular state and side-effects system for your swift application.

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages