Giter VIP home page Giter VIP logo

publisher.js's Introduction

publisher.js

feature-rich publish / subscribe system.

Guide

Read the guide to learn how to use publisher.

Installation and Universal JavaScript Support

publisher works as an AMD module, a Node.js module, or a plain object.

AMD (RequireJS) installation

Place publisher.js in your application and require it as usual, it registers anonymously.

require(['path/to/publisher'], function (publisher) {
  /* Do stuff with publisher here */
});

Node.js Installation

Install with npm

npm install publisher

Include like everything else

var publisher = require('publisher');

Other browser usage

If neither AMD nor Node.js are detected, publisher is global with a noConflict that restores the previous publisher definition and returns the publisher object.

publisher
publisher.noConflict();

License & Copyright

Copyright (c) Ryan Florence

MIT-Style License

Contributing

Fork, create a topic branch, send a pull request :D

Development dependencies

While publisher has no dependencies, developing it does.

You'll need to install some stuff to run the tests and generate docs. There's a script in bin to help. First make sure you've got Node.js, npm, and Python installed, then simply run from the repository root:

$ ./bin/setup-dev

Running tests

$ ./bin/run-tests
# or
$ tap test/test.js

Generating docs

$ ./bin/generate-docs

publisher.js's People

Contributors

ryanflorence avatar mjtognetti avatar

Stargazers

Ryan Purcell avatar Dominik Deobald avatar Hüseyin Mert avatar Marc Cantwell avatar 杨斌 avatar  avatar Cem Gencer avatar  avatar Yurij B. avatar Will Bamford avatar MOULRON avatar Greg D'Angelo avatar  avatar Zdenek Kostal avatar Byron Ruth avatar Neville Franks avatar Paul Bombo avatar Aleksej Romanovskij avatar Pavlo Machekhin avatar Ted Lin avatar John Cleveley avatar  avatar Fabrizio Alonso Hernández Hernández avatar Joel Van Horn avatar Elvis Luciano Guimarães avatar Merrick Christensen avatar Edmundas Kondrašovas avatar  avatar Master of life avatar Damian Nicholson avatar Oskar Krawczyk avatar James Gardner avatar James J. Ye avatar Lawrence Carvalho avatar Thomas Aylott avatar

Watchers

 avatar James Cloos avatar  avatar

publisher.js's Issues

Feature request: add a way to handle all messages of a topic

Whats currently missing is a way to subscribe to all messages of a topic or even all messages flowing to publisher to log them. This could be useful for automatically do something with sub topics which the system dosent know before.

An possible way to do this, would be something like that:

publisher.subscribe('sensors/*', function(data){
..
});

Errors as AMD module with RequireJS Optimization

When run as an AMD module and optimized by @jrburke 's RequireJS, Publisher fails to be defined as a module. Instead an empty define('publisher', function(){}) is produced, breaking any code Publisher-dependent code.

Quoting @jrburke from ded/morpheus#19 , in which an identical problem and its solution are discussed:

The issue is that the requirejs optimizer uses an AST to find define() calls that look like AMD define calls. Since define(definition) is a bit too generic it skips it and puts in an empty module for the 'morpheus' name.

Two possible easy fixes:

  1. Use a function literal:

if (typeof define == 'function') define(function(){return definition()})

  1. Or just pass name to the function:

if (typeof define == 'function') define(name, definition)

access the arguments in an after callback

the registration of an after callback is currently function(returnValue, object), ideally it should be something like function(returnValue, object, arg1, arg2, …) so that you can access the arguments without having to also create a before and cache them.

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.