Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
grdsdev committed Dec 3, 2024
1 parent f637fb4 commit 22d82e9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Sources/Realtime/V2/RealtimeClientV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,23 @@ public final class RealtimeClientV2: Sendable {
}

/// Sets the JWT access token used for channel subscription authorization and Realtime RLS.
/// - Parameter token: A JWT string.
public func setAuth(_ token: String?) async {
mutableState.withValue {
///
/// If `token` is nil it will use the ``RealtimeClientOptions/accessToken`` callback function or the token set on the client.
///
/// On callback used, it will set the value of the token internal to the client.
/// - Parameter token: A JWT string to override the token set on the client.
public func setAuth(_ token: String? = nil) async {
var token = token

if token == nil {
token = try? await options.accessToken?()
}

if token == nil {
token = mutableState.accessToken
}

mutableState.withValue { [token] in
$0.accessToken = token
}

Expand Down

0 comments on commit 22d82e9

Please sign in to comment.