mirror of
https://github.com/wisplite/tether-ts.git
synced 2026-05-01 06:22:41 -05:00
fix json parsing error
This commit is contained in:
Vendored
+2
-2
@@ -47,8 +47,8 @@ export class TetherClient {
|
|||||||
mutation_id: mutation_id
|
mutation_id: mutation_id
|
||||||
}));
|
}));
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.websocketHandler.onMutation = (data) => {
|
this.websocketHandler.onMutation = (mutation_id, data) => {
|
||||||
if (data.mutation_id === mutation_id) {
|
if (mutation_id === mutation_id) {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ export declare class WebSocketHandler {
|
|||||||
private maxReconnectAttempts;
|
private maxReconnectAttempts;
|
||||||
private reconnectInterval;
|
private reconnectInterval;
|
||||||
private sendQueue;
|
private sendQueue;
|
||||||
onMutation: (data: any) => void;
|
onMutation: (mutation_id: string, data: any) => void;
|
||||||
startConnection: (url: string) => void;
|
startConnection: (url: string) => void;
|
||||||
attemptReconnect: () => void;
|
attemptReconnect: () => void;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
|
|||||||
Vendored
+1
-1
@@ -28,7 +28,7 @@ export class WebSocketHandler {
|
|||||||
this.onQuery(data.location, data.data);
|
this.onQuery(data.location, data.data);
|
||||||
}
|
}
|
||||||
else if (data.type === 'mutation') {
|
else if (data.type === 'mutation') {
|
||||||
this.onMutation(data.data);
|
this.onMutation(data.mutation_id || '', data.data);
|
||||||
}
|
}
|
||||||
else if (data.type === 'error') {
|
else if (data.type === 'error') {
|
||||||
console.error(data.error);
|
console.error(data.error);
|
||||||
|
|||||||
+2
-2
@@ -52,8 +52,8 @@ export class TetherClient {
|
|||||||
mutation_id: mutation_id
|
mutation_id: mutation_id
|
||||||
}));
|
}));
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.websocketHandler.onMutation = (data) => {
|
this.websocketHandler.onMutation = (mutation_id: string, data: any) => {
|
||||||
if (data.mutation_id === mutation_id) {
|
if (mutation_id === mutation_id) {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export class WebSocketHandler {
|
|||||||
private maxReconnectAttempts: number = 5;
|
private maxReconnectAttempts: number = 5;
|
||||||
private reconnectInterval: number = 1000;
|
private reconnectInterval: number = 1000;
|
||||||
private sendQueue: string[] = [];
|
private sendQueue: string[] = [];
|
||||||
public onMutation: (data: any) => void = () => {};
|
public onMutation: (mutation_id: string, data: any) => void = () => {};
|
||||||
startConnection = (url: string) => {
|
startConnection = (url: string) => {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.ws = new WebSocket(url);
|
this.ws = new WebSocket(url);
|
||||||
@@ -30,11 +30,12 @@ export class WebSocketHandler {
|
|||||||
location?: string;
|
location?: string;
|
||||||
data?: unknown;
|
data?: unknown;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
mutation_id?: string;
|
||||||
};
|
};
|
||||||
if (data.type === 'query') {
|
if (data.type === 'query') {
|
||||||
this.onQuery(data.location, data.data);
|
this.onQuery(data.location, data.data);
|
||||||
} else if (data.type === 'mutation') {
|
} else if (data.type === 'mutation') {
|
||||||
this.onMutation(data.data);
|
this.onMutation(data.mutation_id || '', data.data);
|
||||||
} else if (data.type === 'error') {
|
} else if (data.type === 'error') {
|
||||||
console.error(data.error);
|
console.error(data.error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user