@redux-observable-backend/websocket

4.4.0 • Public • Published

Redux Observable Backend - WebSockets

What is this library?

For an example use case, look at ./app.js.

Installation

This package requires you also install these peer dependencies:

  • @redux-observable-backend/node
  • @redux-observable-backend/redux-utils
  • rxjs

npm

npm i rxjs@redux-observable-backend/websocket @redux-observable-backend/node @redux-observable-backend/redux-utils

yarn

yarn add rxjs @redux-observable-backend/websocket @redux-observable-backend/node @redux-observable-backend/redux-utils

API

Redux

  • createHttpServers
  • createWebSocketServers
  • ofReponseType
  • ofRequestType
  • webSocketsEpic
  • webSocketsReducers

Custom Configuration

WebSocket Server

To configure the Webpack listener, you have 3 options available to modify in your ./localConfig.js:

module.exports = { // ... other config options ... hostname, port, protocol, }

Testing

Join a Channel

To test joining a channel, load up a browser, and go to about:blank.

Then paste this into the devtools console:

webSocket = new WebSocket('ws://localhost:3000', 'v1')
webSocket.onmessage = console.log
webSocket.onerror = console.error
webSocket.onclose = console.info
webSocket.onopen = () => {
	console.log('READY')

	webSocket
	.send(
		JSON
		.stringify({
			channelName: 'TestChannel',
			type: 'REQUEST::JOIN_CHANNEL',
		})
	)
}

Readme

Keywords

none

Package Sidebar

Install

npm i @redux-observable-backend/websocket

Weekly Downloads

13

Version

4.4.0

License

MITNFA

Unpacked Size

45.3 kB

Total Files

71

Last publish

Collaborators

  • sawtaytoes