mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
tweaks and minor fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f4631e561f
commit
2c36fc11d3
@ -40,6 +40,7 @@ var object = require('lib/object')
|
|||||||
// the same effect as passing the same value to resolve(..) of a Promise
|
// the same effect as passing the same value to resolve(..) of a Promise
|
||||||
// object...
|
// object...
|
||||||
//
|
//
|
||||||
|
// XXX should this be a separate package???
|
||||||
// XXX can we make this an instance of Promise for passing the
|
// XXX can we make this an instance of Promise for passing the
|
||||||
// x instanceof Promise test???
|
// x instanceof Promise test???
|
||||||
var CooperativePromisePrototype = {
|
var CooperativePromisePrototype = {
|
||||||
@ -114,18 +115,23 @@ var CooperativePromisePrototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var CooperativePromise =
|
var CooperativePromise =
|
||||||
|
module.CooperativePromise =
|
||||||
object.makeConstructor('CooperativePromise',
|
object.makeConstructor('CooperativePromise',
|
||||||
Promise,
|
Promise,
|
||||||
CooperativePromisePrototype)
|
CooperativePromisePrototype)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
var makeProtocolHandiler = function(protocol, func){
|
// XXX would be nice to list the protocols supported by the action in
|
||||||
|
// an action attr...
|
||||||
|
var makeProtocolHandler =
|
||||||
|
module.makeProtocolHandler =
|
||||||
|
function(protocol, func){
|
||||||
return function(id){
|
return function(id){
|
||||||
return id.startsWith(protocol + ':')
|
return id.startsWith(protocol + ':')
|
||||||
&& function(res){ res.set(func.apply(this, arguments)) } } }
|
&& function(res){
|
||||||
|
res.set(func.apply(this, [].slice.call(arguments, 1))) }}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -204,6 +210,11 @@ var PeerActions = actions.Actions({
|
|||||||
// XXX
|
// XXX
|
||||||
})],
|
})],
|
||||||
|
|
||||||
|
peerCall: ['- Peer/',
|
||||||
|
function(id, action){ return new CooperativePromise() }],
|
||||||
|
peerApply: ['- Peer/',
|
||||||
|
function(id, action, args){ return new CooperativePromise() }],
|
||||||
|
|
||||||
peerList: ['- Peer/',
|
peerList: ['- Peer/',
|
||||||
function(){ return Object.keys(this.__peers || {}) }],
|
function(){ return Object.keys(this.__peers || {}) }],
|
||||||
// XXX format spec!!!
|
// XXX format spec!!!
|
||||||
@ -216,11 +227,6 @@ var PeerActions = actions.Actions({
|
|||||||
// XXX
|
// XXX
|
||||||
}],
|
}],
|
||||||
|
|
||||||
peerCall: ['- Peer/',
|
|
||||||
function(id, action){ return new CooperativePromise() }],
|
|
||||||
peerApply: ['- Peer/',
|
|
||||||
function(id, action, args){ return new CooperativePromise() }],
|
|
||||||
|
|
||||||
// XXX if no actions are given, proxy all...
|
// XXX if no actions are given, proxy all...
|
||||||
// XXX also proxy descriptors???
|
// XXX also proxy descriptors???
|
||||||
peerMixin: ['- Peer/',
|
peerMixin: ['- Peer/',
|
||||||
@ -266,7 +272,7 @@ module.Peer = core.ImageGridFeatures.Feature({
|
|||||||
// out a cooperative mechanic to return promises...
|
// out a cooperative mechanic to return promises...
|
||||||
var ChildProcessPeerActions = actions.Actions({
|
var ChildProcessPeerActions = actions.Actions({
|
||||||
peerConnect: ['- Peer/',
|
peerConnect: ['- Peer/',
|
||||||
makeProtocolHandiler('child', function(id, options){
|
makeProtocolHandler('child', function(id, options){
|
||||||
// XXX need a cooperative way to pass this to the root method return...
|
// XXX need a cooperative way to pass this to the root method return...
|
||||||
return new Promise((function(resolve, reject){
|
return new Promise((function(resolve, reject){
|
||||||
// already connected...
|
// already connected...
|
||||||
@ -280,7 +286,7 @@ var ChildProcessPeerActions = actions.Actions({
|
|||||||
}).bind(this))
|
}).bind(this))
|
||||||
})],
|
})],
|
||||||
peerDisconnect: ['- Peer/',
|
peerDisconnect: ['- Peer/',
|
||||||
makeProtocolHandiler('child', function(id){
|
makeProtocolHandler('child', function(id){
|
||||||
// XXX need a cooperative way to pass this to the root method return...
|
// XXX need a cooperative way to pass this to the root method return...
|
||||||
return new Promise((function(resolve, reject){
|
return new Promise((function(resolve, reject){
|
||||||
var that = this
|
var that = this
|
||||||
@ -301,14 +307,14 @@ var ChildProcessPeerActions = actions.Actions({
|
|||||||
})],
|
})],
|
||||||
|
|
||||||
peerCall: ['- Peer/',
|
peerCall: ['- Peer/',
|
||||||
makeProtocolHandiler('child', function(id, action){
|
makeProtocolHandler('child', function(id, action){
|
||||||
// XXX need a cooperative way to pass this to the root method return...
|
// XXX need a cooperative way to pass this to the root method return...
|
||||||
return new Promise((function(resolve, reject){
|
return new Promise((function(resolve, reject){
|
||||||
// XXX
|
// XXX
|
||||||
}).bind(this))
|
}).bind(this))
|
||||||
})],
|
})],
|
||||||
peerApply: ['- Peer/',
|
peerApply: ['- Peer/',
|
||||||
makeProtocolHandiler('child', function(id, action, args){
|
makeProtocolHandler('child', function(id, action, args){
|
||||||
// XXX need a cooperative way to pass this to the root method return...
|
// XXX need a cooperative way to pass this to the root method return...
|
||||||
return new Promise((function(resolve, reject){
|
return new Promise((function(resolve, reject){
|
||||||
// XXX
|
// XXX
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user