rxprotoplex
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -15,7 +15,6 @@ export * from "./lib/onConnection$.js"; | ||
export * from "./lib/consumePlexStream.js"; | ||
export * from "./lib/onConnectionAndRead$.js"; | ||
// export useful functionalities. | ||
export * from "./lib/get.js"; | ||
export {onConnectionAndRead$} from "./lib/onConnectionAndRead$.js"; | ||
export * from "./lib/get.js"; |
import {plexIdConfigOrganizeArguments} from "./plexIdConfigOrganizeArguments.js"; | ||
import {fromEventPattern} from "rxjs"; | ||
import {fromEvent, fromEventPattern, take, takeUntil} from "rxjs"; | ||
import {ofChannel} from "./ofChannel.js"; | ||
import {asPlex} from "./asPlex.js"; | ||
@@ -24,18 +25,17 @@ /** | ||
(plex, id, config = {}) => { | ||
const _plex = asPlex(plex); | ||
const stream = _plex.mux.stream; | ||
const close$ = fromEvent(stream, "close").pipe(take(1)); | ||
return fromEventPattern( | ||
handler => { | ||
console.log(`Listening on channel ${id}`); | ||
return plex.listen(id, config).on("connection", handler); | ||
return _plex.listen(id, config).on("connection", handler); | ||
}, | ||
handler => { | ||
try { | ||
console.log(`Unlistening on channel ${id}`); | ||
plex.unlisten({id, ...config}); | ||
plex.off("connection", handler); | ||
} catch (e) { | ||
debugger; | ||
} | ||
console.log(`Unlistening on channel ${id}`); | ||
_plex.unlisten({id, ...config}); | ||
_plex.off("connection", handler); | ||
} | ||
).pipe(ofChannel({id, protocol: config.protocol})); | ||
).pipe(takeUntil(close$), ofChannel({id, protocol: config.protocol})); | ||
} | ||
); |
{ | ||
"name": "rxprotoplex", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A utility library for working with Plex-based connections and streams with RxJS operators.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
33314
617