Skip to content

Remove private typealiases to fix generated documentation#554

Merged
tonidero merged 1 commit into
mainfrom
csdk-300
Jul 1, 2022
Merged

Remove private typealiases to fix generated documentation#554
tonidero merged 1 commit into
mainfrom
csdk-300

Conversation

@tonidero

@tonidero tonidero commented Jul 1, 2022

Copy link
Copy Markdown
Contributor

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

import com.revenuecat.purchases.models.StoreTransaction

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

Copy link
Copy Markdown
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


/**
* Make a purchase.
* Make a purchase upgrading from a previous sku.

Copy link
Copy Markdown
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
@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
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
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