Skip to content

Make the EKEventStore instance a Singleton#552

Open
AlexisChoupault wants to merge 1 commit intobuilttoroam:developfrom
sncf-connect-tech:develop
Open

Make the EKEventStore instance a Singleton#552
AlexisChoupault wants to merge 1 commit intobuilttoroam:developfrom
sncf-connect-tech:develop

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