@logux/core
Advanced tools
Comparing version 0.8.2 to 0.8.3
@@ -5,2 +5,3 @@ import { createNanoEvents } from 'nanoevents' | ||
constructor(pair, type) { | ||
this.connecting = false | ||
this.connected = false | ||
@@ -16,7 +17,13 @@ this.emitter = createNanoEvents() | ||
} else { | ||
this.connecting = true | ||
this.emitter.emit('connecting') | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
if (!this.connecting) { | ||
resolve() | ||
return | ||
} | ||
this.other().connected = true | ||
this.connected = true | ||
this.connecting = false | ||
this.other().emitter.emit('connect') | ||
@@ -31,5 +38,7 @@ this.emitter.emit('connect') | ||
disconnect(reason) { | ||
if (!this.connected) { | ||
throw new Error('Connection already finished') | ||
} else { | ||
if (this.connecting) { | ||
this.connecting = false | ||
this.emitter.emit('disconnect', reason) | ||
return Promise.resolve() | ||
} else if (this.connected) { | ||
this.connected = false | ||
@@ -44,2 +53,4 @@ this.emitter.emit('disconnect', reason) | ||
}) | ||
} else { | ||
throw new Error('Connection already finished') | ||
} | ||
@@ -46,0 +57,0 @@ } |
{ | ||
"name": "@logux/core", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"description": "Logux core components", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
103893
3565