Skip to content

Commit

Permalink
[doc] Straightforward example in the README
Browse files Browse the repository at this point in the history
  • Loading branch information
jfhbrook committed Nov 10, 2011
1 parent 5d545ef commit a0459bd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 23 deletions.
74 changes: 54 additions & 20 deletions README.md
@@ -1,25 +1,71 @@
# broadway

Lightweight application extensibility and composition with a twist of feature
reflection.
*Lightweight application extensibility and composition with a twist of feature
reflection.*

In other words: Broadway is a lightweight plugin system.

## Example

```javascript
var broadway = require('broadway');
### app.js
```js
var broadway = require("broadway");

var app = new broadway.App();

// Attach some plugin to app
app.use(require('./plugins').);
// Passes the second argument to `helloworld.attach`.
app.use(require("./plugins/helloworld"), { "delimiter": "!" } );

app.init(function (err) {
if (err) {
throw err;
}
});

app.hello("world");
```

## Motivation
### plugins/helloworld.js

```js

// exports.attach gets called by broadway on app.use
exports.attach = function (options) {

this.hello = function (world) {
console.log("Hello "+ world + options.delimiter || ".");
}

};

// exports.init gets called by broadway on `app.init`.
exports.init = function (done) {

Lorem ipsum
// This plugin doesn't require any initialization step.
return done();

};
```

### run it!

```bash
josh@onix:~/dev/broadway/examples$ node simple/app.js
Hello world!
josh@onix:~/dev/broadway/examples$
```

## Installation

### Installing npm (node package manager)
``` bash
$ curl http://npmjs.org/install.sh | sh
```

### Installing broadway
``` bash
$ [sudo] npm install broadway
```

## API

Expand Down Expand Up @@ -59,18 +105,6 @@ var plugin = {

See [EventEmitter2][2] documentation for more information.

## Installation

### Installing npm (node package manager)
``` bash
$ curl http://npmjs.org/install.sh | sh
```

### Installing broadway
``` bash
$ [sudo] npm install broadway
```

## Tests
All tests are written with [vows][0] and should be run with [npm][1]:

Expand Down
5 changes: 2 additions & 3 deletions examples/simple/app.js
Expand Up @@ -2,9 +2,8 @@ var broadway = require("broadway");

var app = new broadway.App();

var helloWorld = require("./plugins/helloworld");

app.use(helloWorld, { "delimiter": "!" } );
// Passes the second argument to `helloworld.attach`.
app.use(require("./plugins/helloworld"), { "delimiter": "!" } );

app.init(function (err) {
if (err) {
Expand Down

0 comments on commit a0459bd

Please sign in to comment.