Latest 0.8.0
Homepage https://github.com/marshallxxx/ReactiveSwiftCoreData
License MIT
Platforms ios 9.3
Dependencies ReactiveSwift
Authors

CI Status
Version
License
Platform

This library is a thin wrapper arround CoreData to stream changes from NSManagedObjectContext.

Requirements

  • Swift 4.1

How to use

ReactiveSwiftCoreData adds .reactive extension on NSManagedObjectContext. This extensions observe changes in managed object context. There is no need for managed object context to be saved in order to propagate events in the signal.

managedObjectContext.reactive.observeContext().observeValues { changeEvent in ... }

Observes changes in the provided managed object context.

public struct CoreDataChangeEvent {
    public let inserted: Set<NSManagedObject>
    public let updated: Set<NSManagedObject>
    public let deleted: Set<NSManagedObject>
    public let refreshed: Set<NSManagedObject>
}

managedObjectContext.reactive.observe(object: managedObject).observeResult { result in ... }

Observe updates of provided object in current context. Reacts to all relationships changes as well. In case object is deleted stream will error CoreDataObserverError.objectDeleted.

managedObjectContext.reactive.observeResult(for: fetchRequest).observeResult { result in .. }

Every time objects are deleted or inserted in managed object context it will fetch again provided request.

Installation

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

pod 'ReactiveSwiftCoreData'

License

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

Latest podspec

{
    "name": "ReactiveSwiftCoreData",
    "version": "0.8.0",
    "summary": "ReactiveSwift wrapper on CoreData",
    "description": "Add reactive extension on NSManagedObjectContext to observe context changes.",
    "homepage": "https://github.com/marshallxxx/ReactiveSwiftCoreData",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "marshallxxx": "[email protected]"
    },
    "source": {
        "git": "https://github.com/marshallxxx/ReactiveSwiftCoreData.git",
        "tag": "0.8.0"
    },
    "social_media_url": "https://twitter.com/ENicolaev",
    "platforms": {
        "ios": "9.3"
    },
    "source_files": "ReactiveSwiftCoreData/Classes/**/*",
    "dependencies": {
        "ReactiveSwift": [
            "~> 3.1"
        ]
    }
}

Pin It on Pinterest

Share This