Socket
Book a DemoInstallSign in
Socket

pazaak

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pazaak

A functional observable library for JS

0.0.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Pazaak

A functional observable library.

Installation

npm install pazaak

Usage

var pazaak = require('pazaak').pazaak;

// Create a new observable
function myObservable() {
 //Return a function that takes a function
 return pazaak(observer => {
   try {
      var handler = ({ pageX, pageY }) => {
         //Observe a change
         observer.next({ x: pageX, y: pageY });
      }
      //Listen to browser mouse moves
      document.addEventListener('mousemove', handler);

      // Call complete after 10 seconds
      setTimeout(() => {
         observer.complete();
         document.removeEventListener('mousemove', handler);
      }, 10000);

      // Returns a destroy function
      return () => {
         document.removeEventListener('mousemove', handler);
      };
   } catch (e) {
      //Handle any errors
      observer.error(e);
   }
 });
}

// Subscribe to the observable (subs has an unsubscribe method to stop listening)
const subs = myObservable().subscribe({
  next({x, y}) {
    console.log(x, y);
  },
  error(e) {
    console.log(e);
  },
  complete() {
    console.log('done');
  }
});

Tests

More tests need written - see contributing section.

npm test

Contributing

Be sure to test and lint.

npm run lint

Keywords

functional

FAQs

Package last updated on 13 Mar 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.