There seem to be a conflict between chaining api and promise-based api. Both of 
them use return value, but chaining api returns `this`, and promise-based one 
returns promise.

Is it possible to use both at the same time?

Here is some abstract example. Suppose we have a class:

```js
function Message(text) {
    var self = Object.create(Message.prototype)
    self.text = text
    return self
}

Message.prototype.send = function(server, callback) {
    servers[server].doStuff(callback)
    return this
}
```

Which can be used this way:

```js
Message("text")
    .send("server1", function() { console.log("message sent to server 1") } )
    .send("server2", function() { console.log("message sent to server 2") } )
```

Some users want to use promises. Ideally, it'll look like that:

```js
Message("text")
    .send("server1")
        .then( function() { console.log("message sent to server 1") } )
    .send("server2")
        .then( function() { console.log("message sent to server 2") } )
```

I'm sure it's possible with prototype injection into promise, but it surely 
sounds weird. Is there a better way?

--
// alex

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/753341411516901%40web14g.yandex.ru.
For more options, visit https://groups.google.com/d/optout.

Reply via email to