Skip to content

1.0.0

Latest

Choose a tag to compare

@Woit Woit released this 28 Nov 14:05
· 2 commits to main since this release
cd7492d

The first stable release: an actor-based, TCA-style store for Swift 6, built on the standard library alone.

API

Core

  • Store<State, Action, Environment>: an actor that owns the state and processes actions one at a time.
    • send(_:) is nonisolated: it enqueues and returns, from any thread, without await.
    • stateStream() yields the current state, then every state that differs from the previous one.
  • Reducer, Middleware, Effect and Logger type aliases.
  • AsyncStream helpers for middlewares: .none, .just(_:), .seq(_:), map(_:) and merge(_:).

Modules (optional, for apps with many features)

  • Module: a feature with its own state, actions and dependencies.
  • ActionRoute: picks the global actions a module handles and wraps its follow-ups back.
  • ModuleRegistry: mounts modules into one store through makeReducers() and makeMiddlewares().

Guarantees

  • One FIFO queue for sent and emitted actions; actions sent from one task keep their order.
  • Reducers run synchronously, in order, on every action. Subscribers see a state only if it changed.
  • Every middleware starts as its own task with the post-reducer state, off the store's actor.
  • Nothing keeps a store alive: once it is released, its state streams finish.
  • There is no cancellation, and follow-ups from different middlewares arrive in no particular order.

STORE.md and MODULES.md describe the exact semantics; from now on they are part of the API, as the README's Source stability section says.

Requirements

Swift 6.0 or later. iOS 15, macOS 12, tvOS 15, watchOS 8, and Linux.

CI runs on Linux with Swift 6.0 and 6.4, and on macOS with Thread Sanitizer. It also builds for iOS and watchOS and checks four upcoming Swift features.