onAuthError property
Optional hook that enables refresh-and-replay.
When an operation fails downstream and this is provided, it is called with the error. If
it resolves to true, the token is fetched again through getToken and the original
operation is re-sent once with the refreshed header. If it resolves to false (or is
null), the error is re-thrown unchanged.
A typical implementation checks for an expired-token signal, for example:
AuthLink(
getToken: () => authStore.token,
onAuthError: (error) =>
error is HttpLinkServerException && error.response.statusCode == 401,
)
Only one replay is attempted: an operation that fails again after the refresh surfaces the second error rather than looping. If the consumer cancels its subscription while the refresh or the replay is in flight, no replay is sent and no further events are emitted.
Implementation
final FutureOr<bool> Function(Object error)? onAuthError;