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

Can you provide a way to completely clean data #67

Closed
9you opened this issue Mar 7, 2017 · 3 comments
Closed

Can you provide a way to completely clean data #67

9you opened this issue Mar 7, 2017 · 3 comments

Comments

@9you
Copy link

9you commented Mar 7, 2017

Hi, I'm writing an application that provide different content for logged in and non-logged in users. So each time user login/logout, I need to completely clean all data from RocketData.

Currently, I'm using removeAllObjects of PINCache. But it may cause problem with ConsistencyManager.

Can you provide an easy way to completely clean data? Thank you!

@plivesey
Copy link
Owner

There was a bit of discussion here: #62

In general, the recommended way is to release all of your data providers. This will in turn cause the listeners on the consistency manager to drop to zero.

It seems like maybe you have data providers that stick around even after logging out? One other work around is to have all data providers listen to a notificaiton:

extension DataProvider {
    init() {
         // other init stuff including calling super.init
        NotificationCenter.default.addListener(to: "logout") { self.data = nil }
    }
}

^^ pseudo code, but you get the idea

Finally, the ConsistencyManager does actually have a function: clearListenersAndCancelAllTasks()

This will basically cause all data providers that are hanging around to be useless (I think until they get new data), but possibly this could help?

@plivesey
Copy link
Owner

Otherwise, what's exactly the expected behavior? Do you want all data providers to nil out? Or something similar?

@9you
Copy link
Author

9you commented Apr 19, 2017

Thanks for your input. Currently, when I user logged out, we removeAllObjects from PINCache and drop whole UI hierarchy and recreated a new one. But sometime old data still alive. I think your work around will work, I will give a try.

@9you 9you closed this as completed Apr 19, 2017
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