defer-to-connect

WebJar for defer-to-connect

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

defer-to-connect
Last Version

Last Version

1.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

defer-to-connect
WebJar for defer-to-connect
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/szmarczak/defer-to-connect

Download defer-to-connect

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/defer-to-connect/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>defer-to-connect</artifactId>
    <version>1.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/defer-to-connect/
implementation 'org.webjars.npm:defer-to-connect:1.1.3'
// https://jarcasting.com/artifacts/org.webjars.npm/defer-to-connect/
implementation ("org.webjars.npm:defer-to-connect:1.1.3")
'org.webjars.npm:defer-to-connect:jar:1.1.3'
<dependency org="org.webjars.npm" name="defer-to-connect" rev="1.1.3">
  <artifact name="defer-to-connect" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='defer-to-connect', version='1.1.3')
)
libraryDependencies += "org.webjars.npm" % "defer-to-connect" % "1.1.3"
[org.webjars.npm/defer-to-connect "1.1.3"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

defer-to-connect

The safe way to handle the connect socket event

Coverage Status

Once you receive the socket, it may be already connected (or disconnected).
To avoid checking that, use defer-to-connect. It'll do that for you.

Usage

const deferToConnect = require('defer-to-connect');

deferToConnect(socket, () => {
    console.log('Connected!');
});

API

deferToConnect(socket, connectListener)

Calls connectListener() when connected.

deferToConnect(socket, listeners)

listeners

An object representing connect, secureConnect and close properties.

Calls connect() when the socket is connected.
Calls secureConnect() when the socket is securely connected.
Calls close() when the socket is destroyed.

License

MIT

Versions

Version
1.1.3