Projects // gopher

What is gopher?

Gopher is a simple JS pub/sub system.

Gopher is tiny. The minified version is less than 500 Bytes.

Gopher broadcasts synchronously and in-order of subscription.

Gopher is compatible with node (CommonJs), RequireJS, and browsers.

What isn't gopher?

Gopher has no bells and whistles.

Gopher does not allow for sub-topic subscriptions.

Example // Usage

function outputToConsole(message){
    console.log(message);
}

var messages = [];
function storeMessage(message){
    messages.push(message);
}

gopher("notification").subscribe(outputToConsole);
gopher("notification").subscribe(storeMessage);

gopher("notification").broadcast("Message one.");
gopher("notification").broadcast("Message two.");

gopher("notification").unsubscribe(outputToConsole);

gopher("notification").broadcast("Message three.");
console.log(messages);


// Console
// --------------------------------------
// >>> Message one.
// >>> Message two.
// >>> [ 'Message one.', 'Message two.', 'Message three.' ]