Update docs, bump version
This commit is contained in:
@@ -20,6 +20,7 @@ Manages authentication state for a socket connection.
|
||||
**Methods:**
|
||||
- `doAuth(sign)` - Authenticate with the relay using provided signing function
|
||||
- `attemptAuth(sign)` - Attempt authentication with timeout handling
|
||||
- `retryAuth(sign)` - Retry authentication by resetting state and attempting auth again
|
||||
- `cleanup()` - Clean up event listeners
|
||||
|
||||
**Events:**
|
||||
@@ -39,4 +40,9 @@ authState.on(AuthStateEvent.Status, (status) => {
|
||||
await authState.attemptAuth(async (template) => {
|
||||
return await signer.signEvent(template)
|
||||
})
|
||||
|
||||
// Retry authentication if needed
|
||||
await authState.retryAuth(async (template) => {
|
||||
return await signer.signEvent(template)
|
||||
})
|
||||
```
|
||||
|
||||
@@ -14,12 +14,13 @@ Creates a writable store that synchronizes with a storage provider using JSON se
|
||||
- `storage` - Storage provider implementing the StorageProvider interface
|
||||
- `defaultValue` - Default value if nothing exists in storage
|
||||
|
||||
**Returns:** Writable Svelte store that persists changes to storage
|
||||
**Returns:** `Synced<T>` - A writable Svelte store with a `ready` promise that resolves when initial storage loading completes
|
||||
|
||||
The store automatically:
|
||||
- Loads initial value from storage on creation
|
||||
- Loads initial value from storage asynchronously on creation
|
||||
- Saves any changes back to storage
|
||||
- Falls back to defaultValue if storage is empty or invalid
|
||||
- Provides a `ready` promise that resolves when initial loading is complete
|
||||
|
||||
## Storage Provider Interface
|
||||
|
||||
@@ -46,6 +47,9 @@ const userPreferences = synced({
|
||||
}
|
||||
})
|
||||
|
||||
// Wait for initial loading to complete if needed
|
||||
await userPreferences.ready
|
||||
|
||||
// Use like any writable store
|
||||
userPreferences.subscribe(prefs => {
|
||||
console.log("Preferences:", prefs)
|
||||
|
||||
Reference in New Issue
Block a user