npm.io
6.14.0 • Published 5d ago

@interopio/core

Licence
MIT
Version
6.14.0
Deps
6
Size
3.3 MB
Vulns
0
Weekly
0

@interopio/core

Overview

The @interopio/core library provides the basic io.Connect interoperability capabilities (Interop API, Shared Contexts API, Pub/Sub API, Logger API, and the legacy Metrics API) and is used internally by all other major io.Connect libraries like @interopio/desktop, @interopio/browser, and more.

Supported runtimes

The supported release scope is current io.Connect Desktop, modern browsers with native WeakRef and FinalizationRegistry, and Node.js 18 or later. Both native APIs are required; Core does not provide a compatibility fallback for them.

Installation

To install the library, execute the following command:

npm install @interopio/core

Usage

The following example demonstrates basic initialization of the @interopio/core library.

For more details on using the capabilities provided by the @interopio/core library, see the respective sections in the io.Connect Desktop official documentation or the io.Connect Browser official documentation.

import IOConnectCore from "@interopio/core";

// Use the initialized API object returned by the factory function to access the io.Connect APIs.
const io = await IOConnectCore();

// Using the io.Connect APIs.
await io.interop.register("myApp", () => {
  console.log("Hello from myApp!");
});
Stream discovery timeouts

io.interop.subscribe() uses the configured discovery timeout, which defaults to 30 seconds. Omitting target selects "best". With waitTimeoutMs: 0, Core performs its initial lookup and, if no matching publisher is present, checks once more on the first asynchronous discovery poll, normally after 500 milliseconds. A publisher visible at that poll can accept the request; otherwise the call rejects. Publisher acceptance has its own methodResponseTimeout.

Keywords