Skip to content

Instantly share code, notes, and snippets.

@Nepoxx
Created May 2, 2016 19:46
Show Gist options
  • Select an option

  • Save Nepoxx/16751b68cb8b0009afda3f7dbc8f18cf to your computer and use it in GitHub Desktop.

Select an option

Save Nepoxx/16751b68cb8b0009afda3f7dbc8f18cf to your computer and use it in GitHub Desktop.

Revisions

  1. Nepoxx created this gist May 2, 2016.
    16 changes: 16 additions & 0 deletions promise.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    this.addNewListener = function(user) {

    joinChannel(user.name);
    return addNewChannelCache(user)
    .then(function(data) {
    return cache.getAsync(user.name);
    })
    .then(function(obj) {
    if (obj == null) {
    throw new Exception('Object was not in cache');
    } else {
    io.of('/' + user._id);
    return obj;
    }
    });
    }