docs: README, CHANGELOG and skill for @rudder/sdk 0.1.0 with generated module clients
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# Player profile + wallets — `client.player`
|
||||
# Player — `client.player`
|
||||
|
||||
`PlayerDomain` (source: `src/domains/PlayerDomain.ts`) — the observable player
|
||||
profile: identity plus currency wallets. Synced under revision key `profile`.
|
||||
profile: player, linked identities, currency wallets and
|
||||
number counters. Synced under revision key `profile`.
|
||||
|
||||
There is no separate wallet service in this SDK. Wallet balances are read from
|
||||
the profile and are credited/debited server-side (admin wallet adjust, module
|
||||
@@ -12,7 +13,7 @@ functions).
|
||||
`client.player` is a `SyncedState<PlayerProfile>`:
|
||||
|
||||
```ts
|
||||
client.player.data // PlayerProfile | undefined
|
||||
client.player.value // PlayerProfile | undefined
|
||||
client.player.status // 'idle' | 'loading' | 'ready' | 'error'
|
||||
client.player.onChange((snapshot) => { /* fires immediately */ });
|
||||
await client.player.load();
|
||||
@@ -23,6 +24,7 @@ await client.player.reload(); // force refetch
|
||||
|
||||
```ts
|
||||
interface PlayerProfile {
|
||||
counters?: { [slug: string]: number }; // client-visible number counters
|
||||
identities?: PlayerProfileIdentity[];
|
||||
player?: Player;
|
||||
wallets?: Wallet[];
|
||||
@@ -51,9 +53,12 @@ interface Wallet {
|
||||
|
||||
## Behavior notes
|
||||
|
||||
- `counters` holds the values of `number` counters whose definition is
|
||||
`client_visible`; hidden counters are left out. Currency counters are in
|
||||
`wallets`, not in `counters`. Counter changes bump the `profile` revision.
|
||||
- Warmed automatically at login (with catalog).
|
||||
- Kept fresh by the revision poll; call `reload()` after a module function
|
||||
that mutates wallets.
|
||||
that changes wallets or counters.
|
||||
- All fields are optional on the wire (`?`); code defensively.
|
||||
- React: `useSyncExternalStore` maps directly onto `onChange` (see the SDK
|
||||
README "React recipe").
|
||||
|
||||
Reference in New Issue
Block a user