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

Make the EKEventStore instance a Singleton #552

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

Conversation

AlexisChoupault
Copy link

Somehow fixes #551

Comment on lines +27 to +33
public let eventStore: EKEventStore

public static let shared = SingleEventStore()

private init() {
eventStore = EKEventStore()
}

Choose a reason for hiding this comment

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

Doesn't this initialise two instances of EKEventStore?

1: eventStore which doesn't appear to be used, and 2: shared

Copy link
Author

@AlexisChoupault AlexisChoupault Nov 14, 2024

Choose a reason for hiding this comment

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

I don't think so. The whole point of the Singleton pattern is that the class and its attributes are instantiated only once at runtime.
In my code the only way to instantiate a SingleEventStore is through its static instance shared, which calls the constructor where eventStore is instantiated (only once)

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.

Singleton pattern on EKEventStore instance
2 participants