Closed serluca closed 7 years ago
Hi @serluca, Thanks for raising this issue. Another option might be using NSAsynchronousFetchRequest
. I won't have time to work on this for the next several days. If you would like to try out your suggestions and/or using an async fetch request, please let me know what you find out.
Hi @scotteg, I'd be happy to implement the solution, when we have one.
My first thought was NSAsynchronousFetchRequest
but it seems that is not possible to use NSAsynchronousFetchRequest
with NSFetchedResultsController
so then is not possible to observe the Fetch Request for future updates.
Wrapping the try self.frc.performFetch()
with performBlock
works but I'm not sure is the best solution, because the user still needs to call rx_entities
using a PrivateQueueConcurrencyType
context, what do you think?
I was thinking more about a solution that is asynchronous by default, unfortunately NSAsynchronousFetchRequest
it can't help, one idea I had was to observe the changes with NSFetchedResultsController
on a child Context and merge the changes using NSManagedObjectContextDidSaveNotification
, then every time the frc delegate calls controllerDidChangeContent
we can then map the new objects using objectWithID
and return the new objects on the given context.
Hi @scotteg
I'm having some issue with the pull request #8, it works great when new contents come in, but it has issues when old contents get updated.
I found that this is an old bug, the issue I have is that as soon the contents get updated disappear from the NSFetchedResultsController
. I'm working on a fix, unfortunately the fix described in the article doesn't work for me.
It also only works when the subscriberContext
gets saved, instead the default NSFetchedResultsController
behaviour it also observe changes that are not saved yet, this can be an issue too.
Let me know if you have any idea
Hi @scotteg any news on this?
Issue
I had a performance issue using the
rx_entities
method. The fetch request that I have to execute is heavy and it blocks the Main thread, and as expected the bottleneck istry self.frc.performFetch()
. So I created another context with the concurrency typePrivateQueueConcurrencyType
and I calledrx_entities
using the new context but nothing thetry self.frc.performFetch()
was still executed on the Main Thread because I was callingrx_entities
on the Main Thread.Proposal
What do you think about wrapping the
try self.frc.performFetch()
andsendNextElement()
withperformBlock
? Or even better to schedulerx_entities
on the context thread.