Home

Awesome

ReactiveCoreData

ReactiveCoreData (RCD) is an attempt to bring Core Data into the ReactiveCocoa (RAC) world.

Currently has several files with the source code, Specta specs and a demo application for the Mac.

To use, copy the source files from ReactiveCoreData folder to your project. You should also have ReactiveCocoa in your project, of course.

Code from the Mac example:

// This part refetches data for the table and puts it into filteredParents
// It either fetches all Parents or filters by name, if there's something in the search field
// It will also refetch, if objectsChanged send a next
RAC(self.filteredParents) = [[[[Parent findAll]
    where:@"name" contains:filterText options:@"cd"]
    sortBy:@"name"]
    fetchWithTrigger:objectsChanged];

Another example of background processing:

[[[[triggerSignal 
    performInBackgroundContext:^(NSManagedObjectContext *context) {
        [Parent insert];
    }]
    saveContext]
    deliverOn:RACScheduler.mainThreadScheduler]
    subscribeNext:^(id _) {
        // Update UI
    }];
    
// We can also react to main context's merge notifications to update the UI
[mainContext.rcd_merged 
    subscribeNext:^(NSNotification *note){
        // Update UI
    }];

See the test Specs for some crude usage examples.

Also checkout the demo application in the project. It shows a simple table-view with Core Data backed storage using ReactiveCoreData and ReactiveCocoa for connecting things.

The headers also provide documentation for the various methods.

It's not feature-complete and more could be done but will be added based on actual usage and your contributions.

That being said, it should work both with shoebox and document-based applications, where there are many object contexts.

Done: