GithubHelp home page GithubHelp logo

observer's Introduction

observer.js

An implementation of the observer design pattern.

Tested Platforms: V8 (Node)

From NPM

npm install observer

Usage

To create an observation table: var EventBroker = require('observer').EventBroker;

var events = new EventBroker;
events.create('foobar');

events.subscribe('foobar', console.log.bind(console,'observer#1:') );
events.subscribe('foobar', console.log.bind(console,'observer#2:') );

events.publish('foobar',3,14);

// => observer#1, 3, 14
// => observer#2, 3, 14

To create an observable class: var Observable = require('observer').Observable, inherits = require('util').inherits;

function Foobar(){
  Observable.call(this);
  this.create('qux');
}

var f = new Foobar();
f.on('qux', console.log.bind(console, 'observer#3:');
f.events.publish('qux',3,14);

// => observer#3, 3, 14

Testing

node test/test.js

observer's People

Contributors

azer avatar cybear avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

observer's Issues

May I use the name 'observer' in npm?

Hi @azer ,

I've noticed this hasn't been touched in 3 years. Is this a working module? If this either doesn't work or you don't plan on supporting it, would you mind letting me use the name 'observer' in npm?

Let me know,
Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.