-
Notifications
You must be signed in to change notification settings - Fork 12
Description
@ifandelse Is there anyway the implementation could be changed to the following:
postal.publish({
channel: 'some.channel',
request: {
topic: 'some.topic',
data: {some: data},
timeout: 2000
},
response: {
onSuccess: function (d, e) { }
onFail: function (err) { }
always: function (d, e, err) { }
}
});
The problem I'm having with the current implementation is that it introduces a whole new approach to publishing by having to work with the channel itself. The approach is different, and yet, fundamentally, there's nothing particularly different about request-response.
Also, I think the then should be internalized (but still conform to the configuration for creating promises, of course). Further, onSuccess, onFail, and always conform to the language of the promises domain.
The approach I take above is crystal clear, and we stay within the confines of how we publish otherwise.
It seems to me that it should be easy enough to ingest the object literal above (request, response), and then wrap the channel in request semantics. The response callbacks could internally be mapped to then. So, in effect, the approach I take above becomes sugar on top of the current implementation.
I do like the subscriber side, though (i.e. envelope.reply({ })).
Just some suggestions...