DailyJS

Node Roundup: promise.io, copromise, Apper

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

frameworks libraries node modules express async promises

Node Roundup: promise.io, copromise, Apper

Posted by Alex R. Young on .
Featured

frameworks libraries node modules express async promises

Node Roundup: promise.io, copromise, Apper

Posted by Alex R. Young on .

promise.io

promise.io (GitHub: krillr / promise.io, License: Apache 2.0, npm: promise.io) by Aaron Krill is an RPC module that uses promises. You can create a server like this:

var server = new PromiseIO({  
  someFunc: function(input) {
    return 'I got: ' + input;
  }
});

server.listen(3000);  

Then the client can call someFunc by connecting to the server:

var client = new PromiseIO();

client.connect('http://localhost:3000').then(function(remote) {  
  return remote.someFunc('my variable!');
}).then(function(returnVal) {
  return console.log(returnVal);
}).catch(function(err) {
  return console.log(err);
});

Internally, q is used for the promise implementation.

copromise

copromise (GitHub: deanlandolt / copromise, License: MIT, npm: copromise) by Dean Landolt is a bit like co, but it automatically lifts values that aren't promises, so you can yield anything.

A copromise represents the eventual value of a coroutine. A coroutine is a generator function where the yield keyword is used to suspend execution to wait on a future value, allowing linear control flow logic for asynchronous code.

Dean announced it on the nodejs list, including some examples and a comparison with the co module.

Apper

Apper (GitHub: asyncanup / apper, License: MIT, npm: apper) by Anup Bishnoi is a real-time framework for single page applications. The idea behind it is to have strong conventions for practices that suit single page apps, including transparent minification and bundling.

It wraps around Express, so route definitions look like a typical Express project, but Apper also has specific places for things like middleware and application settings.

If you're new to Express then you might like working with the conventions Apper uses, and it will at least push you away from putting everything in a monolithic app.js file.