Skip to content

Commit

Permalink
feat!: Remove function literal with receiver. (#103)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removes function literal receiver from await
extensions that don't require it.

Change-Id: If646464c26351a41114fb8390734f62f72ed80f9
  • Loading branch information
arriolac committed Mar 15, 2022
1 parent a9643e7 commit f4f6061
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import kotlinx.coroutines.tasks.await
@ExperimentalCoroutinesApi
public suspend fun PlacesClient.awaitFetchPhoto(
photoMetadata: PhotoMetadata,
actions: FetchPhotoRequest.Builder.() -> Unit
actions: FetchPhotoRequest.Builder.() -> Unit = {}
): FetchPhotoResponse {
val cancellationTokenSource = CancellationTokenSource()
val request = FetchPhotoRequest.builder(photoMetadata)
Expand All @@ -61,12 +61,10 @@ public suspend fun PlacesClient.awaitFetchPhoto(
public suspend fun PlacesClient.awaitFetchPlace(
placeId: String,
placeFields: List<Place.Field>,
actions: FetchPlaceRequest.Builder.() -> Unit
): FetchPlaceResponse {
val cancellationTokenSource = CancellationTokenSource()
val request = FetchPlaceRequest.builder(placeId, placeFields)
.setCancellationToken(cancellationTokenSource.token)
.apply(actions)
.build()
return this.fetchPlace(request).await(cancellationTokenSource)
}
Expand Down Expand Up @@ -100,13 +98,11 @@ public suspend fun PlacesClient.awaitFindAutocompletePredictions(
)
@ExperimentalCoroutinesApi
public suspend fun PlacesClient.awaitFindCurrentPlace(
placeFields: List<Place.Field>,
actions: FindCurrentPlaceRequest.Builder.() -> Unit
placeFields: List<Place.Field>
): FindCurrentPlaceResponse {
val cancellationTokenSource = CancellationTokenSource()
val request = FindCurrentPlaceRequest.builder(placeFields)
.setCancellationToken(cancellationTokenSource.token)
.apply(actions)
.build()
return this.findCurrentPlace(request).await(cancellationTokenSource)
}

0 comments on commit f4f6061

Please sign in to comment.