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

Determine when all buckets have been indexed? #300

Closed
codeboost opened this issue Jun 26, 2014 · 5 comments
Closed

Determine when all buckets have been indexed? #300

codeboost opened this issue Jun 26, 2014 · 5 comments
Milestone

Comments

@codeboost
Copy link

The problem:
When the app is first started, I need to know:

  • if there is any data in the 'cloud' for my app
  • if there is data, I'd like to know when the initial seed of all the buckets is completed.

If there is no previous data, my app creates some default objects. However, those objects will be duplicated if previous data existed and simperium downloads it.
My idea is to show a spinner while the buckets are downloaded and not let the user interact with the app during this time.

Is there a better way to do this ?

@jleandroperez
Copy link
Contributor

This delegate method will get hit, as soon as indexing is complete, which is where you could hook up the process you've outlined.

In order to solve this, without waiting for the index to be retrieved, you could run a quick CoreData fetch, check if the objects are already there, and if not, insert them. In order not to create duplicates, your objects should have predictable simperiumKeys.

However:
The current behavior is to rebase local changes, on top of the remote object. Which means that: right now, even if you implement a custom predictable key for your seed objects, whenever the user re-logs in, and retrieves the remote index, "the pristine seed data" will be applied on top of the remote data.

I've added this ticket to implement a mechanism that would allow you to disable the "Rebase Local Changes", when the object already exist remotely.

@codeboost
Copy link
Author

The delegate method notifies about one bucket only. Is there a way to determine when all of them are indexed ?

Is there a way to predictably create the simperiumKey ? Can I use the hash of some values as simperiumKey ?

@jleandroperez
Copy link
Contributor

@codeboost I'm afraid there is no -all buckets ready- callback, at least not for now!.

You can use any function you wish to calculate + set your simperiumKey attributes. Probably a hash of some values will do the trick, for this scenario.

Please, bear in mind that if you proceed implementing that mechanism (predictable keys!), until this issue is closed, remote entities will get overwritten by the local values of your objects.

@codeboost
Copy link
Author

Thanks, I'll keep an eye on that issue and hopefully it will work out of the box.

@jleandroperez jleandroperez added this to the v0.6.6 milestone Jun 30, 2014
@jleandroperez
Copy link
Contributor

Closing this issue in favor of #301.

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