本文整理汇总了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');
}
})();