trpc-browser
Advanced tools
{ | ||
"name": "trpc-browser", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "tRPC adapters and links for everywhere in the browser", | ||
@@ -5,0 +5,0 @@ "author": "Janek Rahrt <janek.rahrt@me.com>, James Berry <jb@jamesbe.com>", |
@@ -6,7 +6,14 @@ /// <reference types="chrome" /> | ||
* | ||
* @param chrome - chrome API | ||
* @param createPort - function to create a port | ||
* @param onConnect - callback when connected | ||
*/ | ||
export declare function autoConnect(createPort: () => chrome.runtime.Port, onConnect: (port: chrome.runtime.Port) => AllowCleanUpFunction): Promise<void>; | ||
/** | ||
* Reconnects a port if it disconnects | ||
* @param port - port to reconnect | ||
* @param createPort - function to create a port | ||
* @param onConnect - callback when connected | ||
*/ | ||
export declare function autoReconnect(port: chrome.runtime.Port, createPort: () => chrome.runtime.Port, onReconnect: (port: chrome.runtime.Port) => AllowCleanUpFunction): void; | ||
export {}; | ||
//# sourceMappingURL=chrome.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.autoConnect = void 0; | ||
exports.autoReconnect = exports.autoConnect = void 0; | ||
const retry_1 = require("./retry"); | ||
@@ -8,3 +8,3 @@ /** | ||
* | ||
* @param chrome - chrome API | ||
* @param createPort - function to create a port | ||
* @param onConnect - callback when connected | ||
@@ -24,2 +24,15 @@ */ | ||
exports.autoConnect = autoConnect; | ||
/** | ||
* Reconnects a port if it disconnects | ||
* @param port - port to reconnect | ||
* @param createPort - function to create a port | ||
* @param onConnect - callback when connected | ||
*/ | ||
function autoReconnect(port, createPort, onReconnect) { | ||
port.onDisconnect.addListener(() => { | ||
console.log('Port disconnected, reconnecting...'); | ||
void autoConnect(createPort, onReconnect); | ||
}); | ||
} | ||
exports.autoReconnect = autoReconnect; | ||
//# sourceMappingURL=chrome.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
73737
1.77%771
2.66%