purchases-flutter icon indicating copy to clipboard operation
purchases-flutter copied to clipboard

Make Purchases a singleton

Open IchordeDionysos opened this issue 4 years ago • 5 comments

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);

IchordeDionysos avatar Feb 22 '21 19:02 IchordeDionysos

@vegaro might be a change worth doing with #149 to minimize breaking changes.

IchordeDionysos avatar Feb 22 '21 19:02 IchordeDionysos

<itsHappening.gif> in our next major, which is soon.

taquitos avatar Oct 14 '21 17:10 taquitos

Is there any chance this moves forward to improve testablity? @vegaro @taquitos

jsgalarraga avatar Mar 09 '23 12:03 jsgalarraga

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

EnduringBeta avatar Aug 17 '23 19:08 EnduringBeta