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

Remove private typealiases to fix generated documentation #554

Merged
merged 1 commit into from
Jul 1, 2022
Merged

Conversation

tonidero
Copy link
Contributor

@tonidero tonidero commented Jul 1, 2022

Description

https://revenuecats.atlassian.net/browse/CSDK-300

This removes all private typealiases from the public api so Dokka can generate the docs appropriately.

This is an example of how it looks:
image

@@ -10,20 +10,12 @@ import com.revenuecat.purchases.interfaces.ReceiveOfferingsCallback
import com.revenuecat.purchases.models.StoreProduct
import com.revenuecat.purchases.models.StoreTransaction

private typealias PurchaseCompletedFunction = (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit
private typealias ProductChangeCompletedFunction = (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe we lose some info from not having the typealias name (for example, these 2 typealiases are almost identical). But I think we earn in making sure devs know exactly what the API looks like, so I think it's a good change overall

@@ -407,7 +407,7 @@ class Purchases internal constructor(
}

/**
* Make a purchase.
* Make a purchase upgrading from a previous sku.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed these since otherwise these 2 methods with the same name had almost the same documentation.

@tonidero tonidero marked this pull request as ready for review July 1, 2022 08:08
@tonidero tonidero requested a review from a team July 1, 2022 08:08
@@ -10,6 +10,8 @@ import com.revenuecat.purchases.interfaces.ProductChangeListener
private typealias DeprecatedPurchaseCompletedFunction = (purchase: Purchase, purchaserInfo: PurchaserInfo) -> Unit
@Deprecated("Purchase replaced with StoreTransaction and PurchaserInfo with CustomerInfo")
private typealias DeprecatedProductChangeCompletedFunction = (purchase: Purchase?, purchaserInfo: PurchaserInfo) -> Unit
private typealias ErrorFunction = (error: PurchasesError) -> Unit
private typealias PurchaseErrorFunction = (error: PurchasesError, userCancelled: Boolean) -> Unit
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left these 2 here since we don't generate docs from these deprecated functions

onError: PurchaseErrorFunction = ON_PURCHASE_ERROR_STUB,
onSuccess: PurchaseCompletedFunction
onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB,
onSuccess: (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh shoot I just realized we have an inconsistency on the order of the functions. Here we have onError first then onSuccess, which is on purpose so folks can omit the last parameter and do:

Purchases.purchaseProductWith(.....) { purchase, customerInfo ->

But other functions have the onError in last place 😮‍💨

Nothing to worry about now but wanted to mention it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh good catch! Yeah... I guess we might want to make it consistent on the next major... But probably we shouldn't change it here.

@tonidero tonidero merged commit 1f22ef6 into main Jul 1, 2022
@tonidero tonidero deleted the csdk-300 branch July 1, 2022 08:38
@tonidero tonidero mentioned this pull request Jul 7, 2022
@vegaro vegaro mentioned this pull request Jul 12, 2022
1 task
@aboedo aboedo mentioned this pull request Jul 13, 2022
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.

2 participants