Skip to content

Revising the implementation #1

@estaylorco

Description

@estaylorco

@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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions