@graphql-live/client
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -30,2 +30,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const onOperationResult = ({ id, patch, isFinal }) => { | ||
var _a, _b, _c, _d; | ||
const record = operations.get(id); | ||
@@ -37,6 +38,6 @@ if (!record) | ||
record.latestResult = applyPatch(deepClone(record.latestResult), patch).newDocument; | ||
record.observer.next(record.latestResult); | ||
(_b = (_a = record.observer).next) === null || _b === void 0 ? void 0 : _b.call(_a, record.latestResult); | ||
if (isFinal) { | ||
operations.delete(id); | ||
record.observer.complete(); | ||
(_d = (_c = record.observer).complete) === null || _d === void 0 ? void 0 : _d.call(_c); | ||
} | ||
@@ -80,5 +81,6 @@ }; | ||
return () => { | ||
var _a; | ||
socket.emit("graphql:unsubscribe", id); | ||
operations.delete(id); | ||
observer.complete(); | ||
(_a = observer.complete) === null || _a === void 0 ? void 0 : _a.call(observer); | ||
}; | ||
@@ -85,0 +87,0 @@ }; |
export * from "./createClient"; | ||
export * from "./urql"; | ||
export * from "./types"; |
export * from "./createClient"; | ||
export * from "./urql"; | ||
export * from "./types"; | ||
//# sourceMappingURL=index.js.map |
@@ -19,5 +19,5 @@ import { ManagerOptions, Socket, SocketOptions } from "socket.io-client"; | ||
export declare type ResultObserver = { | ||
next(value: ExecutionResult): void; | ||
error(error: any): void; | ||
complete(): void; | ||
next?(value: ExecutionResult): void; | ||
error?(error: any): void; | ||
complete?(): void; | ||
}; | ||
@@ -24,0 +24,0 @@ export declare type OperationPayload<TContext = any> = { |
import { ClientOptions } from "."; | ||
export declare function liveExchange<TContext = any>(options: ClientOptions<TContext>): import("urql").Exchange; | ||
export declare function liveExchange<TContext = any>(options?: ClientOptions<TContext>): import("urql").Exchange; |
import { subscriptionExchange } from "urql"; | ||
import { createClient } from "."; | ||
export function liveExchange(options) { | ||
export function liveExchange(options = {}) { | ||
const { execute } = createClient(options); | ||
@@ -5,0 +5,0 @@ return subscriptionExchange({ |
{ | ||
"name": "@graphql-live/client", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "The client part of the GraphQLive package", | ||
@@ -33,2 +33,3 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@apollo/client": "^3.3.12", | ||
"@types/node": "^14.14.35", | ||
@@ -35,0 +36,0 @@ "typescript": "^4.2.3", |
@@ -45,6 +45,6 @@ import { io } from "socket.io-client"; | ||
).newDocument; | ||
record.observer.next(record.latestResult); | ||
record.observer.next?.(record.latestResult); | ||
if (isFinal) { | ||
operations.delete(id); | ||
record.observer.complete(); | ||
record.observer.complete?.(); | ||
} | ||
@@ -91,3 +91,3 @@ }; | ||
operations.delete(id); | ||
observer.complete(); | ||
observer.complete?.(); | ||
}; | ||
@@ -94,0 +94,0 @@ }; |
export * from "./createClient"; | ||
export * from "./urql"; | ||
export * from "./types"; |
@@ -23,5 +23,5 @@ import { ManagerOptions, Socket, SocketOptions } from "socket.io-client"; | ||
export type ResultObserver = { | ||
next(value: ExecutionResult): void; | ||
error(error: any): void; | ||
complete(): void; | ||
next?(value: ExecutionResult): void; | ||
error?(error: any): void; | ||
complete?(): void; | ||
}; | ||
@@ -28,0 +28,0 @@ |
import { subscriptionExchange } from "urql"; | ||
import { ClientOptions, createClient } from "."; | ||
export function liveExchange<TContext = any>(options: ClientOptions<TContext>) { | ||
export function liveExchange<TContext = any>( | ||
options: ClientOptions<TContext> = {} | ||
) { | ||
const { execute } = createClient(options); | ||
@@ -6,0 +8,0 @@ return subscriptionExchange({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
283321
24
374
1
187
4