Giter VIP home page Giter VIP logo

postal.when's People

Contributors

ifandelse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

postal.when's Issues

Bug: postal.when callback never gets called when incoming messages do not have a data property

Hello,

I've just discovered that publishing messages to a when array of channelDefs will fail to cause the when callback to be called if the messages do not have a data property. I'm having to do this:

postal.publish({ channel: 'c', topic: 't', data: {} });  // <- empty data property

I'm not suggesting that the data property's value must be an empty plain object, only that it must be present. If I remove the data property, the when callback never gets called.

I don't think this is appropriate. It's not always the case that the message payloads are of interest. Meaningfulness might actually simply be that all of the messages were published and received [within the timeout interval], without regard for the payloads.

Please advise.

Thank you!

"You can only make functions into Conduits."

When running the example using postal.when-0.2.0, postal-0.10.1, conduit-0.3.2, lodash-2.4.1-compat, in Chrome v36, I received the following error:

"You can only make functions into Conduits." from conduit.js

By adding an explicit, empty callback function to each of the channels, the issue appears to have gone away.

postal.when([
    { channel: "ChannelA", topic: "topic.on.channel.a", callback: function() {} },
    { channel: "ChannelB", topic: "topic.on.channel.b", callback: function() {} },
    { channel: "ChannelC", topic: "topic.on.channel.c", callback: function() {} },
    { channel: "ChannelD", topic: "topic.on.channel.d", callback: function() {} },
], function(a, b, c, d){
    _.each(arguments, function(x) {
        $('body').append("<div>" + x + "</div>");
    });
});

postal.publish( { channel: "ChannelD", topic: "topic.on.channel.d", data: "And it's testable!" } );
postal.publish( { channel: "ChannelB", topic: "topic.on.channel.b", data: "Deferred behavior!" } );
postal.publish( { channel: "ChannelA", topic: "topic.on.channel.a", data: "Hey look!" } );
postal.publish( { channel: "ChannelC", topic: "topic.on.channel.c", data: "Via message bus!" } ); 

Hopefully this help. Thanks for your hard work on postal.when. It's very helpful.

Incompatibility with RequireJS

Regular postal works great with require; if you publish on a channel from a dependency, the module depending on it receives that transmission through a subscription. I.E. if 'app/app' is defined like so:

define(['postal', 'postal.when'], function (postal) { 
  var app = postal;
  return app;
});

Then, the following works:

requirejs(['app/app', 'app/homeBackgroundSlider'],
  function (    app,       homeBackgroundSlider) {
    // homeBackgroundSlider sends homeBackgroundSlider.complete on the default channel
    app.channel().subscribe('homeBackgroundSlider.complete', function() {
      console.log('this works');
    });
  });

But this won't work:

requirejs(['app/app', 'app/homeBackgroundSlider'],
  function (    app,       homeBackgroundSlider) {
    // homeBackgroundSlider sends homeBackgroundSlider.complete on the default channel
    app.when([{topic: 'homeBackgroundSlider.complete'}], function() {
      console.log('this doesn\'t work');
    });
  });

Now I've only started digging into postal.when, but my guess is that because 'app/homeBackgroundSlider' is included as a dependency, it actually executes before the module above, meaning that it publishes before the when statement listens. However, that it works using "vanilla" postal's subscribe means that perhaps this issue has to do with the postal.when code specifically. In fact, I had this issue elsewhere and created my own postal.when functionality in code, I just don't want to have to do that (makes postal.when useless in requireJS applications).

How to use postal.when in the browser using AMD

(using 0.9.0)

I've been using postal successfully for a while now, and I reach a point where I need the functionality in postal.when. But I haven't been able to get it to work in a browser using AMD.

The example given on GitHub for AMD doesn't seem plausible: 3 modules are required, but only two are defined in the function arguments. The example goes on to use "postal.when", but postal is never required (only its path is defined). And 'postal.when' is required, but the path is never defined, nor does it show up in the function arguments.

How, exactly, do we use postal.when under AMD and in a browser?

Thank you.

Is postal.when abandoned?

The last commit was 3 years ago, the repository has 4 issues opened and 3 pull request awaiting merge.

Is it abandoned?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.