From f4631e561f287c889f032e122771d27ed13c390c Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 25 Feb 2017 01:23:07 +0300 Subject: [PATCH] notes and docs... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/peer.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ui (gen4)/features/peer.js b/ui (gen4)/features/peer.js index 4dd4f09b..c39b3205 100755 --- a/ui (gen4)/features/peer.js +++ b/ui (gen4)/features/peer.js @@ -21,6 +21,25 @@ var object = require('lib/object') /*********************************************************************/ // helpers... +// Cooperative promise object... +// +// This is like a promise but is not resolved internally, rather this +// resolves (is set) via a different promise of value passed to it via +// the .set(..) method... +// +// Example: +// // create a promise... +// var p = (new CooperativePromise()) +// // bind normally... +// .then(function(){ .. }) +// +// // this will resolve p and trigger all the .then(..) callbacks... +// p.set(new Promise(function(resolve, reject){ resolve() })) +// +// Note that .set(..) can be passed any value, passing a non-promise has +// the same effect as passing the same value to resolve(..) of a Promise +// object... +// // XXX can we make this an instance of Promise for passing the // x instanceof Promise test??? var CooperativePromisePrototype = { @@ -103,15 +122,6 @@ object.makeConstructor('CooperativePromise', //--------------------------------------------------------------------- -// XXX should this parse out the protocol??? -// ...technically we no longer need it.... -/* -var makeProtocolHandiler = function(protocol, func){ - return function(id){ - return id.startsWith(protocol + ':') - && func.apply(this, arguments) } } -//*/ - var makeProtocolHandiler = function(protocol, func){ return function(id){ return id.startsWith(protocol + ':')