Giter Site home page Giter Site logo

Comments (2)

ifandelse avatar ifandelse commented on July 18, 2024

Thanks! You're in luck - this is actually possible now:

var channel = postal.channel( 'ui' );
var sub = channel.subscribe( topics.POPOVER_CLOSE, function( envelope ) { close( envelope ); } )
                          .withContext( this.busContext )
                          .withConstraint( function( envelope ) {
                              return envelope.target === 'globalActionsPopover';
                          });

The function you pass to withConstraint is a predicate - returning true if you want the subscription callback to fire or false if not. IIRC, the current postal API allows for multiple constraints to be registered via withConstraints([pred1, pred2, pred3]), etc. Be aware that this will most likely change with future postal 0.9.x (which hasn't stabilized yet). Future postal 0.9.x will actually provide a pipeline hook to allow you to make adding predicate constraints like this much more expressive.

Check out the SubscriptionDefinition API Documentation to see what members on the prototype can be called to further configure a subscription....

from postal.js.

estaylorco avatar estaylorco commented on July 18, 2024

That's just awesome! I don't know how I missed this. Thank you!

from postal.js.

Related Issues (20)

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.