# @dcos/connection-manager

> This package allows to manage connections inside the browser and order them in a queue by priority.

Latest version **0.4.0** (published 2019-06-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @dcos/connection-manager
pnpm add @dcos/connection-manager
yarn add @dcos/connection-manager
bun add @dcos/connection-manager
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2019-06-25 |
| First published | 2017-10-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 166.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | brandonc, dschmidt, fabsn, juliangieseke, mesosphere-frontend-ci, mesosphere-it, mperrotti, natmegs, nlight, orlandohohmeier, specone, tattdcodemonkey, tnguyen0 |

## Links

- npm: https://www.npmjs.com/package/@dcos/connection-manager
- Repository: https://github.com/dcos-labs/connection-manager
- Homepage: https://github.com/dcos-labs/connection-manager#readme
- Issues: https://github.com/dcos-labs/connection-manager/issues
- npm.io page: https://npm.io/package/@dcos/connection-manager

## Dependencies (1)

- [immutable](https://npm.io/package/immutable.md) ^3.8.2

## Recent versions

- 0.4.0 (latest) — 2019-06-25
- 0.3.1 — 2019-06-13
- 0.3.0 — 2019-04-17
- 0.2.2 — 2019-02-16
- 0.2.1 — 2017-12-14
- 0.2.0 — 2017-11-24
- 0.1.2 — 2017-10-24
- 0.1.1 — 2017-10-24
- 0.1.0 — 2017-10-24

## README

# Connection Manager [![Build Status](https://travis-ci.org/dcos-labs/connection-manager.svg?branch=master)](https://travis-ci.org/dcos-labs/connection-manager)

This package allows to manage connections inside the browser and order them in a queue by priority.

Browsers can open only a limited amount of connections so when you urgently need one there may not be a slot. This package solves the issue by providing a manager that enqueues all requested connections and priorities them accordingly.

## Usage

```javascript
import { XHRConnection, ConnectionEvent } from "@dcos/connections";
import ConnectionManager from "@dcos/connection-manager";

const connection = new XHRConnection("http://127.0.0.1");
connection.on(ConnectionEvent.CLOSE, function(event) {
  // doing something with event.target.response
});
ConnectionManager.enqueue(connection);
```

Connection will be opened by the manager once there's a slot available.

## Connection types

At the moment `connection-manager` package exposes only one connection `XHRConnection` that wraps `XmlHttpRequest`

```javascript
const connection = new XHRConnection("http://127.0.0.1", {
  method: "POST",
  body: "{}",
  contentType: "json"
});
```

## Creating your own connection type

If you want to create your own connection type that will be compatible with the manager please extend `AbstractConnection`.
Have a look at `Connections/AbstractConnection.js` for more info.

---
_Source: https://npm.io/package/@dcos/connection-manager · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
