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

Adding a hasAppBeenUpdated property #21

Open
ChocoChipset opened this issue Feb 18, 2015 · 1 comment
Open

Adding a hasAppBeenUpdated property #21

ChocoChipset opened this issue Feb 18, 2015 · 1 comment

Comments

@ChocoChipset
Copy link
Contributor

I came across the following scenario:

I have a cache file that I would like to flush on every app update. With the current implementation MTMigration it currently looks like:

[MTMigration applicationUpdateBlock:^{
    flushCache();
}];

if (isCacheAvailable) {    // (1)
    loadCache();
} else {
    writeCache();
}

However, unless a synchronization method is introduced, there is no guarantee that the cache file will be flushed before (1).

Adding a hasAppBeenUpdated property would allow the synchronous execution of code in an easier way:

if (isCacheAvailable && 
    [MTMigration hasAppBeenUpdated] == NO) {
    loadCache();
} else {
    writeCache();
}

Let me know what you think, @pwightman

@revolter
Copy link

Why not move the if and else blocks inside the applicationUpdateBlock's completion block?

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