purchases-flutter
purchases-flutter copied to clipboard
Make Purchases a singleton
Purchases is currently only like a namespace for several functions and has several static functions.
As the functions are static it makes it hard to mock Purchases to write tests if data is correctly passed to RevenueCat.
Would be better to adopt something like: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/cloud_firestore/cloud_firestore/lib/src/firestore.dart
This would allow to mock and verify calls to Purchases, like:
verify(mockPurchases.setCampaign(campaign));
verifyNoMoreInteractions(mockPurchases.setCampaign);
@vegaro might be a change worth doing with #149 to minimize breaking changes.
<itsHappening.gif> in our next major, which is soon.
Is there any chance this moves forward to improve testablity? @vegaro @taquitos
I ran into this limitation today. Just to understand, @taquitos said this would be in the next major, which at the time (Oct 2021 - 3.4.5) would have been v4. We're now at 5.6.1.
It's fine to need to change direction or not complete a feature, but communicating that and setting expectations would be very helpful. @vegaro