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

Threads #1

Open
zdnk opened this issue Jul 24, 2017 · 1 comment
Open

Threads #1

zdnk opened this issue Jul 24, 2017 · 1 comment

Comments

@zdnk
Copy link

zdnk commented Jul 24, 2017

I have read your article and I have a question regarding realm and threads. Your current implementation of RealmContxt is assuming it will be called just from the main thread I suppose. Well in many cases you want to make calls from other threads and have it actually do the work on other threads. How would you approach and achieve this with this model? I guess the same goes for CoreData and contexts.

@ennioma
Copy link
Owner

ennioma commented Jul 24, 2017

Hi @zdenektopic,
After that article I've published StorageKit (https://github.com/StorageKit/storagekit).

You can take a look at https://github.com/StorageKit/StorageKit/blob/develop/Source/Storages/Realm/RealmDataStorage.swift and especially at the method getThreadSafeEntities.

The idea there is that you can "move" entities between threads in a safe way. In the example projects I've shown how to perform queries in background and getting data on the main thread.

With storagekit the goal is exactly to provide the same behavior to both realm and CoreData.

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

No branches or pull requests

2 participants