Latest 0.1.0
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0

Atlas Swift Store

Atlas is a redux store for your swift apps without the reducer layer



Atlas is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'AtlasSwift'

How it works

there are 3 main components

  • State
  • Actions
  • Guards


// The state should be always a struct, to ensure immutability
struct CountState {
    var count: Int

let store = Atlas(state: CountState(
    count: 0


Actions can be synchronous or asynchronous

struct Increment: AtlasAction {
    func handle(state: CountState, context: AtlasActionContext<CountState>) {
        var newState   = state
        newState.count = result
        // context.error(YourError)


// With a completition callback
store.dispatch(Increment()) { (error?, state) in
    print("done! ", state.count)


Guards track the store lifecycle.
In future, they will include also a middleware-like function.

struct Logger: AtlasGuard {
    // By default, this function returns true
    func shouldUpdate<A: AtlasAction>(state: State, action: A) -> Bool {
        return true

    func willUpdate<A: AtlasAction>(state: State, action: A) {
        print("will update!", state.count)

    func didUpdate<A: AtlasAction>(state: State, action: A) {
        print("update!", state.count)

let store = Atlas(state: YourState(), guards: [ Logger() ])


extension YourController: AtlasSubscriber {

    override func viewDidAppear() {

    func newState(_ state: CountState) {
        print("count state changed!")

Subscriber Should Update

Avoiding unneeded updates and subscribing to a specific part of the store.
By default, the shouldUpdate function returns always true.
To use this method, the state should be a value type.

extension YourController: AtlasSubscriber {

    // subscription code...

    func shouldUpdate(prevState: CountState?, newState: CountState) -> Bool {
        return prevState?.count != newState.count


  • Atlas uses a serial queue to dispatch every action, so you can be sure that your actions will be executed in the invokation order
  • The dispatch function is async, to avoid deadlocks. To track its end, you can use the completition argument
  • The subcribe function has a second argument "queue", to subscribe a class on a specific queue.

That’s all!

Inspired by ReSwift and Redux


Atlas is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "AtlasSwift",
    "version": "0.1.0",
    "summary": "Atlas is a redux-like store for your swift apps without the reducer layer",
    "description": "Atlas is a redux-like store for your swift iOS/macOS/tvOS apps without the reducer layer",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Giuseppe": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    "source_files": "AtlasSwift/Classes/**/*",
    "exclude_files": "AtlasSwift/Example/**/*.plist",
    "swift_version": "4.2",
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "4.2"

Pin It on Pinterest

Share This