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

Delay New Entities Initialization #418

Closed
jleandroperez opened this issue Dec 3, 2014 · 4 comments · Fixed by #419 or #443
Closed

Delay New Entities Initialization #418

jleandroperez opened this issue Dec 3, 2014 · 4 comments · Fixed by #419 or #443
Assignees
Labels
Milestone

Comments

@jleandroperez
Copy link
Contributor

As soon as Simperium is initialized, it begins listening to NSManagedObjectContext change notifications.
All of the inserted objects will get their simperiumKey assigned, even if the user is not logged in.

Let's provide a mechanism to delay the simperiumKey assignment: this way, developers will be able to pull objects from X service while Simperium is initialized, and provide a getSimperiumKeyFromLegacyKey getter, which allows to set a custom simperiumKey.

Props to @astralbodies for finding this issue (Thank you Aaron!).

@prvnl
Copy link
Contributor

prvnl commented Dec 3, 2014

Hi @jleandroperez,

Should this issue already be closed, since I'm not able to find the getSimperiumLegacyKey getter? Or should we create and trigger this ourselves? Because of this change, in the current develop branche an object created before authentication will never get synced and thus will cause out of sync devices:
Simperium tried to send changes for an object with a nil simperiumKey (Entity)
Is this intentional behavior or just not finished yet?

Regards Patrick

@jleandroperez jleandroperez reopened this Dec 3, 2014
@jleandroperez
Copy link
Contributor Author

@prvnl not sure what might have caused the nil simperiumKey error (this routine should assign a simperiumKey, if it was not set, at the moment of authentication).

However, we've found out that disabling MOC hooks before auth might have side effects for developers who use a custom simperiumKey. We'll revert this merge for the time being, (+ thanks for the heads up!).

@jleandroperez
Copy link
Contributor Author

@prvnl (by the way) this is the getter. Name fixed, thanks!

@jleandroperez jleandroperez modified the milestones: v0.7.6, v0.7.7 Jan 6, 2015
@jleandroperez jleandroperez modified the milestones: v0.7.7, v0.7.8 Feb 4, 2015
@jleandroperez jleandroperez changed the title Do not assign simperiumKey's while De-Authenticated Delay New Entities Initialization Feb 4, 2015
jleandroperez added a commit that referenced this issue Feb 4, 2015
…ization

Implements delaysNewObjectsInitialization property
@jleandroperez
Copy link
Contributor Author

Note:

Usage for the new property is as follows:

  • Implement a getter called getSimperiumKeyFromLegacyKey in the NSManagedObject subclass'ess, as required.
  • Set delaysNewObjectsInitialization to YES
  • Proceed importing objects.
  • Whenever you save the MainMOC, the getter getSimperiumKeyFromLegacyKey will be called, for each one of the inserted entities. This way, you may provide a custom simperiumKey, derived from other properties (and thus, preventing duplicates).
  • Please, remember to set delaysNewObjectsInitialization back to NO. Otherwise, newly inserted objects won't get a simperiumKey until the moc is saved.

Thanks!

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