Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

redux-saga-event-iterator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-saga-event-iterator

An easy way of consuming an EventEmitter (e.g. socket.io) in redux-saga

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

redux-saga-event-iterator

Build Status Coverage Status

An easy way of consuming an EventEmitter (e.g. socket.io) in redux-saga

Installation

Install using npm:

$ npm install --save redux-saga-event-iterator

Example

import {call} from 'redux-saga/effects';
import eventIterator from 'redux-saga-event-iterator';
import io from 'socket.io-client';

const socketClient = io('localhost:12345');

const listenerSaga = function * (eventName) {
  const {nextEvent, removeListener} = yield call(eventIterator, socketClient, eventName);

  while (true) {
    const payload = yield call(nextEvent);

    // Do something with payload
  }

  // Optionally remove listener, further calls to nextEvent will throw an error
  yield call(removeListener);
};

Testing

To run the tests:

$ npm test

Contributing

Feel free to create a pull request. Make sure to lint and test:

$ npm run lint && npm run test

License

MIT - see LICENSE

Keywords

FAQs

Package last updated on 05 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc