Skip to content

Commit

Permalink
feat(js-sdk): add update subscription message type
Browse files Browse the repository at this point in the history
Co-Authored-By: Jayant Krishnamurthy <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and Jayant Krishnamurthy committed Dec 18, 2024
1 parent 0b5003c commit 175631a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lazer/sdk/js/examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,14 @@ client.ws.addEventListener("open", () => {
channel: "fixed_rate@200ms",
jsonBinaryEncoding: "hex",
});

// Example: Update an existing subscription
setTimeout(() => {
client.send({
type: "updateSubscription",
subscriptionId: 1,
priceFeedIds: [1, 2, 3],
properties: ["price", "bestBidPrice"],
});
}, 2000); // Wait 2 seconds before updating
});
6 changes: 6 additions & 0 deletions lazer/sdk/js/src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export type Request =
| {
type: "unsubscribe";
subscriptionId: number;
}
| {
type: "updateSubscription";
subscriptionId: number;
priceFeedIds: number[];
properties: PriceFeedProperty[];
};

export type ParsedFeedPayload = {
Expand Down

0 comments on commit 175631a

Please sign in to comment.