fix(config): update npmextra configuration and improve README: rename package keys, add release registry config, clarify waitUntilPresent timeout and notification/persistence behavior
This commit is contained in:
21
readme.md
21
readme.md
@@ -145,19 +145,26 @@ if (currentState) {
|
||||
console.log('Current user:', currentState.username);
|
||||
}
|
||||
|
||||
// Wait for a specific state condition
|
||||
// Wait for state to be present
|
||||
await userStatePart.waitUntilPresent();
|
||||
|
||||
// Wait for a specific property to be present
|
||||
await userStatePart.waitUntilPresent(state => state.username);
|
||||
|
||||
// Wait with a timeout (throws error if condition not met within timeout)
|
||||
try {
|
||||
await userStatePart.waitUntilPresent(state => state.username, 5000); // 5 second timeout
|
||||
} catch (error) {
|
||||
console.error('Timed out waiting for username');
|
||||
}
|
||||
|
||||
// Setup initial state with async operations
|
||||
await userStatePart.stateSetup(async (statePart) => {
|
||||
const userData = await fetchUserData();
|
||||
return { ...statePart.getState(), ...userData };
|
||||
});
|
||||
|
||||
// Defer notification to end of call stack
|
||||
// Defer notification to end of call stack (debounced)
|
||||
userStatePart.notifyChangeCumulative();
|
||||
```
|
||||
|
||||
@@ -168,7 +175,7 @@ userStatePart.notifyChangeCumulative();
|
||||
```typescript
|
||||
const settingsStatePart = await myAppSmartState.getStatePart<ISettingsState>(
|
||||
AppStateParts.SettingsState,
|
||||
{ theme: 'light' }, // Initial state
|
||||
{ theme: 'light' }, // Initial/default state
|
||||
'persistent' // Mode
|
||||
);
|
||||
```
|
||||
@@ -176,7 +183,8 @@ const settingsStatePart = await myAppSmartState.getStatePart<ISettingsState>(
|
||||
Persistent state automatically:
|
||||
- Saves state changes to IndexedDB
|
||||
- Restores state on application restart
|
||||
- Manages storage with configurable database and store names
|
||||
- Merges persisted values with defaults (persisted values take precedence)
|
||||
- Ensures atomic writes (persistence happens before memory update)
|
||||
|
||||
### State Validation
|
||||
|
||||
@@ -200,9 +208,10 @@ class ValidatedStatePart<T> extends StatePart<string, T> {
|
||||
|
||||
- **🔒 Async State Hash Detection**: Uses SHA256 hashing to detect actual state changes, preventing unnecessary notifications when state values haven't truly changed
|
||||
- **🚫 Duplicate Prevention**: Identical state updates are automatically filtered out
|
||||
- **📦 Cumulative Notifications**: Batch multiple state changes into a single notification using `notifyChangeCumulative()`
|
||||
- **📦 Cumulative Notifications**: Batch multiple state changes into a single notification using `notifyChangeCumulative()` with automatic debouncing
|
||||
- **🎯 Selective Subscriptions**: Use selectors to subscribe only to specific state properties
|
||||
- **✨ Undefined State Filtering**: The `select()` method automatically filters out undefined states
|
||||
- **⚡ Concurrent Access Safety**: Prevents race conditions when multiple calls request the same state part simultaneously
|
||||
|
||||
### RxJS Integration
|
||||
|
||||
@@ -297,6 +306,8 @@ await loginAction.trigger({ username: 'john', email: 'john@example.com' });
|
||||
| ✅ **Validated** | Built-in state validation with extensible validation logic |
|
||||
| 🎭 **Flexible init modes** | Choose how state parts are initialized |
|
||||
| 📦 **Zero config** | Works out of the box with sensible defaults |
|
||||
| 🛡️ **Race condition safe** | Concurrent state part creation is handled safely |
|
||||
| ⏱️ **Timeout support** | `waitUntilPresent` supports optional timeouts |
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
|
||||
Reference in New Issue
Block a user