Skip to content
Olivier Wietrich edited this page Apr 20, 2014 · 9 revisions

Concept

Wall reduces the complexity of your web application by splitting it into small and self contained modules (or apps). An app is highly extensible, configurable and communicates through event messages.

Everything has been made to save you some precious time!

Create an app

An app is the interface that will help you to divide everything up into smaller parts with lower complexity and responsibility.

var wall = require('wall');
var app = wall();

Its small and clean API is the only thing you have to know in order to use wall into your projects. An app is not invasive and can easily be used in your existing projects.

it is better to have one app per file and to expose it with module.exports

Compose your application

Composing your application with wall is like playing with legos : you assemble multiple interlocking bricks with different shapes and colours. Well an app is a brick and its stud is the app interface.

var chat = wall();
app.use('chat', chat);

An app can be assembled and connected in many ways, to build whatever you want. Like a lego brick it has one colour and one shape which make it easier to maintain and reuse.

It is also a black box which doesn't know anything from the other apps. It means you can add, remove or break an app, the whole application will still work.

Extend your app

An app can be extended with plugins. For example, you could send message through a proxy to a remove server as following:

chat.use(ajax);
chat.use(proxy('myproxy.com'));

The interface to add a plugin or an app is the same (use) and you'll be able to use wall in a minute.

If you need to use the same plugin multiple times in different apps, you can use the wall plugin injector as below:

var wall = require('wall');

wall
  .inject('data')
  .use(ajax)
  .use(proxy('myproxy.com'));

var app = wall('data');
var other = wall('data');

configuration

In order to be reused, an app has to be configurable. Things which are hard coded are difficult to maintain!

chat.set('user', 'bredele');
chat.get('proxy'); // => myproxy.com 

See API for more details.

You can also pass a configuration from the plugin injector:

var wall = require('wall');

wall
  .inject('data', {
     server: 'myproxy.com'
   })
  .use(ajax)
  .use(proxy);

event bus

Once composed together, apps can send messages or expose services. That's the only way they have to communicate each other. It helps to maintain your code by avoiding cross referencing, memory leaks and others. Because an app doesn't hold the reference of an other, if one break the other will be still running.

chat.emit('message');
chat.on('join room', function(){
  //do something
});

See API for more details.