Skip to content

Commit

Permalink
Add migration guides
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Nov 1, 2023
1 parent f92f6cd commit 269cde5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Migration Guide

This is a migration guide from **1.x** to **2.0.0**.


## 1. Dependencies

First, you should use add additional libraries to fully migrate from 1.x version.

```groovy
implementation("com.github.skydoves:sandwich:$version")
implementation("com.github.skydoves:sandwich-retrofit:$version")
implementation("com.github.skydoves:sandwich-retrofit-serialization:$version")
```

## 2. AdapterFactory and Interceptor

If you were using `ApiResponseCallAdapterFactory` and `EmptyBodyInterceptor`, the package name should be change like so:

```diff
- import com.skydoves.sandwich.adapters.ApiResponseCallAdapterFactory
+ import com.skydoves.sandwich.retrofit.adapters.ApiResponseCallAdapterFactory

- import com.skydoves.sandwich.interceptors.EmptyBodyInterceptor
+ import com.skydoves.sandwich.retrofit.interceptors.EmptyBodyInterceptor
```

## 3. Operator

If you're using [Operator](operator.md), the override function should be change like the code below:

```diff
class TestApiResponseSuspendOperator<T>(
private val onSuccess: suspend () -> Unit,
private val onError: suspend () -> Unit,
private val onException: suspend () -> Unit,
) : ApiResponseSuspendOperator<T>() {

override suspend fun onSuccess(apiResponse: ApiResponse.Success<T>) = onSuccess()

- override suspend fun onError(apiResponse: ApiResponse.Failure.Error<T>) = onError()
+ override suspend fun onError(apiResponse: ApiResponse.Failure.Error) = onError()

- override suspend fun onException(apiResponse: ApiResponse.Failure.Exception<T>) = onException()
+ override suspend fun onException(apiResponse: ApiResponse.Failure.Exception) = onException()
}
```

## 4. ApiResponse.error(throwable)

The previous `ApiResponse.error(throwable)` function was renamed to `ApiResponse.exception(throwable)`.

```diff
- val apiResponse = ApiResponse.error(throwable)
+ val apiResponse = ApiResponse.exception(throwable)
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ nav:
- 'Merge': merge.md
- 'Global Handling': global.md
- 'Empty Body': empty-body.md
- 'Migration Guide': migration.md
- 'Sponsor 🩷': sponsor.md

# Repository
Expand Down

0 comments on commit 269cde5

Please sign in to comment.