當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript server.injectWithName函數代碼示例

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

    }
})()
開發者ID:domojs,項目名稱:lifttt,代碼行數:32,代碼來源:index.ts

示例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",
//.........這裏部分代碼省略.........
開發者ID:domojs,項目名稱:domojs-pioneer,代碼行數:101,代碼來源:index.ts

示例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');
    }
})();

開發者ID:domojs,項目名稱:domojs-media-kodi,代碼行數:11,代碼來源:index.ts


注:本文中的@akala/server.injectWithName函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。