Last active
February 3, 2023 01:36
-
-
Save riscait/64bdbff28d010c8313da71df1c75ba15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Definition | |
@Riverpod(keepAlive: true) | |
_RefreshToken refreshToken(RefreshTokenRef ref) => _RefreshToken(ref); | |
class _RefreshToken { | |
const _RefreshToken(this.ref); | |
final Ref ref; | |
Future<RefreshTokenResponse> call({ | |
required RefreshTokenBody body, | |
}) async { | |
final client = ref.watch(restClientProvider); | |
final response = await client.refreshToken(body); | |
return response.data; | |
} | |
} | |
/// call | |
Future<void> callToSingleProvider() async { | |
final container = ProviderContainer(); | |
const body = RefreshTokenBody(userId: 'USER_001'); | |
final response = await container.read(refreshTokenProvider)(body: body); | |
print(response); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Definition | |
@Riverpod(keepAlive: true) | |
Future<RefreshTokenResponse> Function({ | |
required RefreshTokenBody body, | |
}) refreshToken( | |
RefreshTokenRef ref, | |
) => | |
({required body}) async { | |
final client = ref.watch(restClientProvider); | |
final response = await client.refreshToken(body); | |
return response.data; | |
}; | |
/// call | |
Future<void> callToSingleProvider() async { | |
final container = ProviderContainer(); | |
const body = RefreshTokenBody(userId: 'USER_001'); | |
final response = await container.read(refreshTokenProvider)(body: body); | |
print(response); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// call | |
Future<void> callDirectRestClient() async { | |
final container = ProviderContainer(); | |
const body = RefreshTokenBody(userId: 'USER_001'); | |
final response = | |
await container.read(favomatchRestClientProvider).refreshToken(body); | |
print(response); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment