connectorx

    1.0.1 • Public • Published

    connectorx

    • Websocket rxjs wrapper
      • json
      • reconnect

    installation

    npm install connectorx
    

    examples

    const { createWebsocketConnection } = require('connectorx')
     
    global.WebSocket = require('ws')
     
    const url = 'wss://echo.websocket.org'
     
    const { connect$, send$, messages$, open$, status$, error$ } = createWebsocketConnection()
     
    connect$.next({ url, protocols: [] })
     
    status$.subscribe(status => console.log('connection', url, status))
     
    error$.subscribe(error => console.log('error', error.message))
     
    open$.subscribe(() => {
      const message = { date: new Date() }
      console.log('Send message', message)
      send$.next({ date: new Date() })
    })
     
    messages$.subscribe(message => {
      console.log('Receive Message', message)
     
      message.date = new Date()
      console.log('Send message', message)
      send$.next(message)
    })

    Install

    npm i connectorx

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    BSD

    Unpacked Size

    17.4 kB

    Total Files

    14

    Last publish

    Collaborators

    • rhrn