Giter Club home page Giter Club 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

Saranga avatar Сергей avatar George ivan avatar Rodrigo Rosenfeld Rosas avatar Nitesh Kumar avatar Mike Talley avatar Peter Craig avatar Michele Piccirillo avatar Isaac A. Dettman avatar Enoi Barrera Guzman avatar Philippe Santana Costa avatar Pedro Casaubon avatar Daidai Xiao avatar Tom avatar  avatar Ron Martinez avatar Roman Romanov avatar Yuhta Nakajima avatar Marshall T. Rose avatar Brad Pillow avatar Volkan Özçelik avatar greengnn avatar Sascha avatar  avatar Puddin' avatar Alvar Laigna avatar  avatar Jesse Wang avatar  avatar

Watchers

James Cloos avatar Nitesh Kumar 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.