Skip to content

Commit

Permalink
chore: update demos to use JSON-RPC responses async iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Aug 12, 2024
1 parent 05e846c commit 1550216
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions wasm-node/javascript/demo/demo-deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ while(true) {

(async () => {
try {
while(true) {
const response = await chain.nextJsonRpcResponse();
for await (const response of chain.jsonRpcResponses) {
socket.send(response);
}
} catch(_error) {}
Expand Down
6 changes: 2 additions & 4 deletions wasm-node/javascript/demo/demo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ wsServer.on('connection', function (connection, request) {

(async () => {
try {
while(true) {
const response = await para.nextJsonRpcResponse();
for await (const response of para.jsonRpcResponses) {
connection.send(response);
}
} catch(_error) {}
Expand All @@ -177,8 +176,7 @@ wsServer.on('connection', function (connection, request) {

(async () => {
try {
while(true) {
const response = await relay.nextJsonRpcResponse();
for await (const response of relay.jsonRpcResponses) {
connection.send(response);
}
} catch(_error) {}
Expand Down
3 changes: 1 addition & 2 deletions wasm-node/javascript/src/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ export interface Chain {

/**
* JSON-RPC responses or notifications to be generated.
*
* @throws {@link AlreadyDestroyedError} If the chain has been removed or the client has been terminated.
*
* @throws {@link JsonRpcDisabledError} If the JSON-RPC system was disabled in the options of the chain.
* @throws {@link CrashError} If the background client has crashed.
*/
Expand Down
2 changes: 1 addition & 1 deletion wasm-node/javascript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"target": "ES6",
"declaration": true,
"strict": true,
"allowUnreachableCode": false,
Expand Down

0 comments on commit 1550216

Please sign in to comment.