Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle all incoming and outgoing messages with RxJS. Add .observable().
- Loading branch information
Showing
9 changed files
with
173 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Rx from 'rxjs'; | ||
|
||
import WebSocketGremlinConnection from '../src/WebSocketGremlinConnection'; | ||
|
||
|
||
const createConnection$ = (port = 8182, host = 'localhost', path = '') => { | ||
const connection = new WebSocketGremlinConnection({ port, host, path }); | ||
const errors$ = Rx.Observable.fromEvent(connection, 'error'); | ||
const open$ = Rx.Observable.fromEvent(connection, 'open'); | ||
const close$ = Rx.Observable.fromEvent(connection, 'close'); | ||
|
||
const connection$ = new Rx.Subject(); | ||
connection$.next(connection); | ||
|
||
return connection$ | ||
.takeUntil(Rx.Observable.merge(errors$, close$)); | ||
} | ||
|
||
const connections$ = new Rx.Subject(); | ||
// const connection$ = createConnection$(); | ||
|
||
connections$.next(createConnection$()); | ||
|
||
|
||
connections$.subscribe( | ||
(item) => { | ||
console.log(':)))))))))))))))))') | ||
console.log('conn', item) | ||
}, | ||
(err) => { | ||
console.log('-------------------') | ||
connections$.next(createConnection$()) | ||
}, | ||
() => console.log('Completed') | ||
); | ||
|
||
// const openConnections$ = open$ | ||
// .takeUntil(Rx.Observable.merge(errors$, close$)) | ||
|
||
|
||
// console.log(connection) | ||
// openConnections$.subscribe( | ||
// (item) => console.log(item), | ||
// (err) => console.error('Err:', err), | ||
// () => console.log('Completed') | ||
// ); | ||
|
||
|
||
// connections$ | ||
|
||
|
||
// console.log(openConnections$) | ||
|
||
|
||
// console.log(Rx.Observable.merge) | ||
|
||
|
||
// const Rx.Observable | ||
// const openConnections$ = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters