@push-rpc/next
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -26,2 +26,3 @@ "use strict"; | ||
try { | ||
const { signal, finished } = timeoutSignal(callTimeout); | ||
const response = await fetch(this.getItemUrl(itemName), { | ||
@@ -35,4 +36,5 @@ method, | ||
body: (0, json_js_1.safeStringify)(params), | ||
signal: AbortSignal.timeout(callTimeout), | ||
signal, | ||
}); | ||
finished(); | ||
if (response.status == 204) { | ||
@@ -71,2 +73,11 @@ return; | ||
exports.HttpClient = HttpClient; | ||
// AbortSignal.timeout polyfill for RN | ||
function timeoutSignal(time) { | ||
const controller = new AbortController(); | ||
const timeout = setTimeout(() => controller.abort(new Error("TimeoutError")), time); | ||
return { | ||
signal: controller.signal, | ||
finished: () => clearTimeout(timeout), | ||
}; | ||
} | ||
//# sourceMappingURL=HttpClient.js.map |
{ | ||
"name": "@push-rpc/next", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -35,2 +35,8 @@ ## Glossary | ||
- Supports compressed HTTP requests. | ||
- Developer friendly - everything is plain TypeScript calls, easy call tracing between client and server, good | ||
integration with IDE & Browser DevTools | ||
- Based on HTTP, easy to integrate with existing infrastructure | ||
- Gradually upgradeable - WS is only used when you need subscriptions | ||
- Supports compressed HTTP requests. | ||
- Server runs on Node.JS, client runs in the Node.JS/Browser/ReactNative. Bun/Deno should also work, but not officially | ||
supported. |
@@ -35,2 +35,4 @@ import {CLIENT_ID_HEADER, RpcErrors} from "../rpc.js" | ||
try { | ||
const {signal, finished} = timeoutSignal(callTimeout) | ||
const response = await fetch(this.getItemUrl(itemName), { | ||
@@ -44,5 +46,7 @@ method, | ||
body: safeStringify(params), | ||
signal: AbortSignal.timeout(callTimeout), | ||
signal, | ||
}) | ||
finished() | ||
if (response.status == 204) { | ||
@@ -86,1 +90,12 @@ return | ||
} | ||
// AbortSignal.timeout polyfill for RN | ||
function timeoutSignal(time: number): {signal: AbortSignal; finished(): void} { | ||
const controller = new AbortController() | ||
const timeout = setTimeout(() => controller.abort(new Error("TimeoutError")), time) | ||
return { | ||
signal: controller.signal, | ||
finished: () => clearTimeout(timeout), | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
199008
4411
41