Skip to content
This repository has been archived by the owner. It is now read-only.
CoreData's concurrent stacks made easy.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Roku.xcodeproj
Sources
Info.plist
LICENSE.md
Package.swift
README.md

README.md

Warning: This project no longer maintained. Consider using NSPersistentContainer.

Roku ()

CoreData's concurrent stacks made easy.

Inspired by Concurrent Core Data Stacks article, WWDC2013 Session 211 and Seru CoreData stack by [kostiakoval].

Usage

Note: Roku has a set of flexible protocols for building stacks but I have not documented the usage of them yet.

import Roku

Initialize StorageModel with a function that creates a new coordinator:

func newPersistentStoreCoordinator() -> NSPersistentStoreCoordinator {
    // Create and return new persistent store coordinator
}

let storage = StorageModel(persistentStoreCoordinator: newPersistentStoreCoordinator())

or migrate an existing persistent store coordinator.

let storage = StorageModel(persistentStoreCoordinator: oldPersistentStoreCoordinator)

Initialize Roku stack with a base stack:

let baseStack = Roku<StackBase>(storage: storage)

or with a nested stack...

let nestedStack = Roku<NestedStackBase>(storage: storage)

or with an independent stack...

let independentStack = Roku<IndependentStackBase>(storage: storage)

or with a custom stack that conforms to StackProtocol and StorageModelContainer protocols.

let myAwesomeStack = Roku<AwesomeStack>(storage: storage)

Enjoy Roku's features 🎉

myStack.withBackgroundContext { context in
    // Do heavy import operations on the background context
}

myStack.persist { error -> Bool in
    // Handle an error

    // If error was successfully handled,
    // `Roku` will repeat save.
    return errorHandled && shouldRepeatSave
}

// Managed object context with main queue concurrency type
myStack.mainObjectContext

// Get `StorageModel` from encapsulated stack
let storage = myStack.withUnderlyingStack { (inout stack: ContextStack) in
    return stack.storage
}

TODO

  • Implement observable NSManagedObjectContext.
  • Implement templates and default implementations.
  • Implement all functionality of Roku class.
  • Finish writing README.md file.
  • Add examples of custom stack templates and implementations.
  • Feature: implement manager for stack with multiple persistent store coordinators.
  • Continuous integration.

License

Available under the MIT license. See license file for more info.

You can’t perform that action at this time.