Skip to content
Discussion options

You must be logged in to vote

What may or may not be an issue is that resetting the cache only ensures that the next injected value that's asked for gets a new value. Any previously injected or resolved values will still exist, and will not be replaced.

Instead of attempting to reset singleton caches, it's usually better to create a manager that tracks the current instance. One that can be cleared as needed.

class FirestoreManager {

    private(set) var current: Firestore?

    func logout() throws {
        // do whatever
        current = nil
    }
    
}

This way anyone who's asked for a FIrestoreManager still has one, and as long as they always go through current you can be sure they're talking to the right one.

E…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by mikeymike9000
Comment options

You must be logged in to vote
1 reply
@hmlongco
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants