Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOIncrementalStore support #31

Closed
colemancda opened this issue Mar 31, 2014 · 1 comment
Closed

NOIncrementalStore support #31

colemancda opened this issue Mar 31, 2014 · 1 comment
Assignees
Labels

Comments

@colemancda
Copy link
Owner

NOIncrementalStore will block its thread while fetching data. NOAPI and NOAPICached store will be integrated into NOIncrementalStore (as properties, categories, in the implementation itself. SNCStore will have a context that serves as cache and a child store that uses NSIncremental store.

@colemancda colemancda added the bug label Mar 31, 2014
@colemancda colemancda self-assigned this Mar 31, 2014
@colemancda
Copy link
Owner Author

Ok, so there are 2 branches for NOIncrementalStore.

Branch 1

  • NOIncrementalStore-support branch integrates NOAPI and NOAPICachedStore and migrates their code into a NSIncrementalStore subclass. NOIncrementalStore uses semaphores that will block the fetch requests and faulting methods and return the data from the server.

Pros:

  • Correct way of implementing a NSIncrementalStore. Uses options dictionary instead of custom properties (besides a NSURLSession property) for server Schema and uses self.URL property correctly.

Cons:

  • Blocks the serial queue on the context that calls it, requiring a separate context for each server request if they are to be performed concurrently.
  • Cannot synchronize with a cache context because fetch requests are not changes, ergo the cached context will not send NSManagedObjectContextObjectsDidChangeNotification, ergo useless for fetched results controller.

Branch 2

  • NOIncrementalStore-support-2 branch's NOIncrementalStore uses a NOAPICachedStore as a property and immediately returns cached values while fetching remote data in the background. The faulting works the same way, returning cached data and sending notifications when the remote fault request (GET) completes.

Pros:

  • Fetch results work better then in NOIncrementalStore-support and a single context can be used (besides the cached context of course but that is sorta hidden).

Cons:

  • Incorrect way of implementing NSIncrementalStore. Not only is self.URL ignored, but the requests are forwarded to another class (not a superclass) and the calling context's managed object model is ignored for a custom property. The options initialization dictionary is ignored.
  • While the fetched results work better then in NOIncrementalStore-support and do not block the context's thread, the error and results from the remote fetch have to be forwarded through NSNotificationCenter and custom notifications.

In the end, NSIncrementalStore does not seem suited for network fetches. While there are way to forward the errors, still have concurrency, and while the Objective-C classes would make network communications completely object oriented, the implementation in the main branch does the best job for what its supposed to do, even if the API could be improved on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant