Flutter-Buddies / App

An app with community features like 'calendar of events' and a showcase of member created widgets
16 stars 18 forks source link

Singleton pattern for repositories? #14

Closed slovnicki closed 3 years ago

slovnicki commented 3 years ago

Maybe implement singleton pattern for repositories if we're not going to use some Provider-like package. Although this is not necessary for repositories to work, it would be an improvement.

Why? Well, we're going to need the same repository on, for example, home page and events page. We would then like it to be exactly the same object. Here's more about singleton pattern: https://refactoring.guru/design-patterns/singleton

joeyda3rd commented 3 years ago

I'm ok with singleton pattern. I haven't used it in practice, but from what I understand it's not exactly easy to run tests, but I don't think that really matters with this app. It's pretty simple data and only a few data repositories. IF this app gets crazy complicated AND we find that singleton becomes a problem for us, we can refactor. Or we can use a provider. I'm open.