-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpostal.when.min.js
More file actions
8 lines (8 loc) · 1.21 KB
/
postal.when.min.js
File metadata and controls
8 lines (8 loc) · 1.21 KB
1
2
3
4
5
6
7
8
/**
* postal.when - A postal.js add-on enabling an aggregated response to a group of messages.
* Author: Jim Cowart (http://freshbrewedcode.com/jimcowart)
* Version: v0.2.0
* Url: http://github.com/postaljs/postal.when
* License(s): MIT
*/
(function(t,n){"object"==typeof module&&module.exports?module.exports=function(t){return n(require("underscore"),t,this)}:"function"==typeof define&&define.amd?define(["underscore","postal"],function(e,o){return n(e,o,t)}):t.postal=n(t._,t.postal,t)})(this,function(t,n,e,o){var c=function(e,c,i,u){var a,r=this,f="[object Function]"===Object.prototype.toString.call(i)?i:function(){},s="[object Object]"===Object.prototype.toString.call(i)?i:u||{},l=[],p=function(){s.timeout&&(a=setTimeout(function(){f({type:"timeout",data:t.pluck(l,"data")})},s.timeout))},d=function(){t.each(l,function(t){t.data=o})},b=function(){var n=t.pluck(l,"data");t.all(n,t.identity)&&(clearTimeout(a),c.apply(this,n),s.once?r.dispose():(d(),p()))};r.dispose=function(){t.each(l,function(t){t.unsubscribe()}),l=[]},t.each(e,function(t){t.callback||(t.callback=function(){});var e=n.subscribe(t);e.data=o,e.subscribe(function(t){e.data=t,b()}),l.push(e)}),p()};return n.when=function(t,n,e,o){return new c(t,n,e,o)},n});