本文整理匯總了TypeScript中@akala/server.injectWithName函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript injectWithName函數的具體用法?TypeScript injectWithName怎麽用?TypeScript injectWithName使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了injectWithName函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
akala.injectWithName(['$isModule', '$master', '$worker'], function (isModule: akala.worker.IsModule, master: akala.worker.MasterRegistration, worker: EventEmitter)
{
if (isModule('@domojs/lifttt'))
{
worker.on('ready', function ()
{
// Called when all modules have been initialized
});
worker.on('after-master', function ()
{
// Called when all modules have been initialized
require('./services/console');
require('./services/fs');
require('./services/http');
require('./api');
});
master(__filename, './master');
akala.injectWithName([AssetRegistration.name], function (virtualasset: PromiseLike<AssetRegistration>)
{
virtualasset.then((va) =>
{
va.register('/js/tiles.js', require.resolve('../tile'));
va.register('/js/routes.js', require.resolve('../routes'));
});
})();
}
})()
示例2: function
akala.worker.createClient('devices').then(function (c)
{
var deviceCollection: { [name: string]: devices.devices.IDevice } = {};
akala.injectWithName(['$worker'], function (worker)
{
function getMainDevice(name)
{
var indexOfDot = name.indexOf('.');
if (indexOfDot > 0)
var mainDevice = name.substr(0, indexOfDot);
else
var mainDevice = name;
return deviceCollection[mainDevice];
}
var client = akala.api.jsonrpcws(devices.deviceType).createClient(c, {
exec: function (p)
{
var cmd = p.command;
var mainDevice = getMainDevice(p.device);
if (p.device != mainDevice.name)
{
switch (p.device.substring(mainDevice.name.length + 1))
{
case 'power':
if (p.command == 'off')
cmd = 'PF'
else
cmd = 'PO'
break;
case 'mute':
if (p.command == 'off')
cmd = 'MF';
else
cmd = 'MO';
break;
case 'volume':
switch (p.command)
{
case 'up':
cmd = 'VU';
break;
case 'down':
cmd = 'VD';
break;
case 'set':
cmd = 'VL';
break;
}
break;
case 'input':
switch (p.command)
{
case 'Game':
cmd = '49FN';
break;
case 'Dvd':
cmd = '04FN';
break;
case 'Sat/Cbl':
cmd = '06FN';
break;
case 'Dvr/Bdr':
cmd = '15FN';
break;
case 'iPod':
cmd = '17FN';
break;
case 'Video':
cmd = '10FN';
break;
case 'BD':
cmd = '25FN';
break;
}
break;
}
}
return api.send(cmd, mainDevice['address']).then((result) => undefined);
},
getStatus: function (device)
{
var mainDevice = getMainDevice(device.device);
if (mainDevice.name == device.device)
return Promise.resolve(mainDevice.status());
else
return Promise.resolve(mainDevice.subdevices[device.device.substring(mainDevice.name.length + 1)].status());
},
save: (p) =>
{
if (p.device.name.indexOf('.') > -1)
return p.device;
deviceCollection[p.device.name] = p.device;
p.device['address'] = p.body.IP || p.device.name;
p.device.statusMethod = 'pull';
p.device.subdevices = [
{
name: "power",
//.........這裏部分代碼省略.........
示例3: function
import * as akala from '@akala/server';
import { EventEmitter } from 'events';
akala.injectWithName(['$isModule'], function (isModule: akala.worker.IsModule)
{
if (isModule('@domojs/media-kodi'))
{
require('./player');
require('./scrapper');
}
})();