Skip to content

Commit

Permalink
docs: Update coinbase ticker to use product id as pk
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Dec 7, 2023
1 parent df87fcb commit e0a8dd8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
7 changes: 6 additions & 1 deletion docs/core/shared/_useLive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import HooksPlayground from '@site/src/components/HooksPlayground';
import { Entity, RestEndpoint } from '@data-client/rest';

export class Ticker extends Entity {
product_id = '';
trade_id = 0;
price = 0;
size = '0';
Expand All @@ -15,7 +16,7 @@ export class Ticker extends Entity {
volume = '';

pk(): string {
return `${this.trade_id}`;
return `${this.product_id}`;
}
static key = 'Ticker';

Expand All @@ -30,6 +31,10 @@ export const getTicker = new RestEndpoint({
path: '/products/:productId/ticker',
schema: Ticker,
pollFrequency: 2000,
process(value, { productId }) {
value.product_id = productId;
return value;
}
});
```

Expand Down
1 change: 0 additions & 1 deletion docs/rest/guides/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const PostResource = createResource({
```

```tsx title="PostItem" collapsed
import { useSuspense } from '@data-client/react';
import { type Post } from './Post';

export default function PostItem({ post }: Props) {
Expand Down
5 changes: 5 additions & 0 deletions examples/nextjs/resources/Ticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Temporal } from '@js-temporal/polyfill';

// Visit https://dataclient.io/docs/guides/resource-types to read more about these definitions
export class Ticker extends Entity {
product_id = '';
trade_id = 0;
price = 0;
size = '0';
Expand Down Expand Up @@ -31,6 +32,10 @@ export const getTicker = new RestEndpoint({
path: '/products/:productId/ticker',
schema: Ticker,
pollFrequency: 2000,
process(value, { productId }) {
value.product_id = productId;
return value;
}
});

export let TickerFixtures: Record<string, FixtureEndpoint> = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Entity, RestEndpoint } from '@data-client/rest';

export class Ticker extends Entity {
product_id = '';
trade_id = 0;
price = 0;
size = '0';
Expand All @@ -27,4 +28,8 @@ export const getTicker = new RestEndpoint({
schema: Ticker,
// in miliseconds
pollFrequency: 2000,
process(value, { productId }) {
value.product_id = productId;
return value;
},
});
8 changes: 6 additions & 2 deletions website/src/components/Playground/StoreInspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ function StoreInspector({
<>
<div className={styles.debugToggle} onClick={toggle}>
Store
<span className={clsx(styles.arrow, rotation, styles.vertical)}></span>
<span className={clsx(styles.arrow, rotation, styles.vertical)}>
</span>
</div>
{isSelected ? <StoreTreeM /> : null}
{isSelected ?
<StoreTreeM />
: null}
</>
);
}
Expand Down

0 comments on commit e0a8dd8

Please sign in to comment.