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

remove initializerQueue, move db logic from init to initializeApiKey,… #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

djih
Copy link
Member

@djih djih commented Aug 10, 2016

… guarded db interactions with apikey check

This is part 1 of the database migration work. We need to migrate any database interaction logic in the init method into the initializeApiKey method since we will need the apiKey to interact with the database. I also run the init logic on the backgroundQueue, removing the need for a separate initializerQueue.

Few things to note:

  • _dbHelper is initialized in initializeApiKey now. Any public methods that interact with the database such as setUserId, setDeviceId, identify, etc need to be guarded with an apiKey check to ensure [self.dbHelper] is available
  • I moved [self addObservers] to initializeApiKey since enterBackground interacts with the DB by saving the current timestamp.
  • Most tests still pass. Just need to flush the background queue instead of the initializerQueue.
  • Reran all tests on iPhone 4, iPhone 5, iPhone 6S Plus, tested demo app on test device

// Name the queue so runOnBackgroundQueue can tell which queue an operation is running
_backgroundQueue.name = BACKGROUND_QUEUE_NAME;

[_initializerQueue addOperationWithBlock:^{
[_backgroundQueue addOperationWithBlock:^{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to make sure here that this is guaranteed to be called before any other _backgroundQueue addOperationWithBlock calls can be made

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just searched through the code and all addOperationWithBlock and runOnBackgroundQueue calls are protected with an apiKey check, so they need to call initializeApiKey before any of those methods work.

@djih djih mentioned this pull request Aug 12, 2016
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

Successfully merging this pull request may close these issues.

None yet

2 participants