Swift Atoms

screenshot of Swift Atoms

Atoms is a powerful and flexible atomic state management library for Swift, designed to create compact, independent global state components with seamless adaptability and composition.

Overview

Atoms is a powerful and flexible atomic state management library for Swift. It is designed to create compact and independent global state components with seamless adaptability and composition. Atoms helps developers overcome challenges in code splitting by providing a more granular level of state management. With Atoms, developers can focus on what they need without worrying about where to put things.

Features

  • Atom: Represents a state for a given value of type T.
  • DerivedAtom: A read-only state derived from other atom states.
  • AsyncAtom: Manages asynchronous operations that produce a value of type T or throw an error, with states represented as AsyncState<T>.
  • AsyncSequenceAtom: Manages the state of an asynchronous sequence producing values of type T or throwing an error, with states represented as AsyncState<T>.
  • GetSetAtom: Custom getter and setter for values of type T.
  • ObservableObjectAtom: Represents a readable state for a given value of type T that conforms to ObservableObject.
  • PublisherAtom: Represents a readable state from a Publisher, with states represented as AsyncState<T>.
  • PublishedAtom: Represents a readable state from a Published property of type T.
  • WillSetAtom: Stores values of type T and performs custom logic before updating the stored value.

Summary

Atoms is a state management library for Swift that provides a granular approach to handling state in SwiftUI applications. It offers a range of atom types to cover various state management scenarios, such as async operations and derived states. Atoms also support property wrappers for easy access to atom values. The library comes with features for dependency injection, adaptive memory management, and built-in debugging support. To install Atoms, use the Swift Package Manager in Xcode.