Supabase.GoTrue.AutoRefresh (supabase_gotrue v0.5.2)
View SourceA GenServer to automatically refresh auth tokens before they expire.
Usage
Add this GenServer to your application's supervision tree:
# In your application.ex
def start(_type, _args) do
children = [
# ... other children
{Supabase.Registry, keys: :unique, name: Supabase.Registry},
{DynamicSupervisor, strategy: :one_for_one, name: Supabase.AutoRefreshSupervisor}
# ... rest of your supervision tree
]
opts = [strategy: :one_for_one, name: YourApp.Supervisor]
Supervisor.start_link(children, opts)
end
Then start the auto-refresh process when you get a new session:
{:ok, pid} = DynamicSupervisor.start_child(
Supabase.AutoRefreshSupervisor,
{Supabase.GoTrue.AutoRefresh, {client, session}}
)
To stop refreshing when the user logs out:
Supabase.GoTrue.AutoRefresh.stop(client)
Summary
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for GenServer.init/1
.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Callback implementation for GenServer.init/1
.