• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript listeners.listeners_on函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@core/util/listeners.listeners_on函数的典型用法代码示例。如果您正苦于以下问题:TypeScript listeners_on函数的具体用法?TypeScript listeners_on怎么用?TypeScript listeners_on使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了listeners_on函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: createTransport

    return __cfg.getScript || file_getScript;
});
export const _file_getStyle = createTransport(function(){
    return __cfg.getStyle || file_getStyle;
});
export const _file_getJson = createTransport(function(){
    return __cfg.getJson || (__cfg as any).getData || file_getJson;
});


listeners_on('config', function (config) {
    var modules = config.modules;
    if (modules == null) {
        return;
    }
    var fn = Loaders[modules];
    if (is_Function(fn) === false) {
        log_warn('Module system is not supported: ' + modules);
        return;
    }
    fn();
});

function createTransport(loaderFactoryFn) {
    return function(path_){
        var fn = loaderFactoryFn(),
            path = path_,
            v = _opts.version;
        if (v != null) {
            path = path_appendQuery(path, 'v', v);
        }
        return fn(path);
开发者ID:atmajs,项目名称:MaskJS,代码行数:32,代码来源:loaders.ts


示例2: listeners_off

        Module.cfg('moduleResolution', 'classic');
        listeners_off('error');
	},

	async 'should load default file in node_modules' () {
		let dom = await renderer_renderAsync(`
            import Foo from '/test/tmpl/npm/foo.mask';

            Foo;
        `);
        
        return UTest.domtest(dom, `
            find ('h4') > text ('EmptyPackage');
        `);
	},
	async 'should fail loading' () {
        var errors = [];
        
		listeners_on('error', assert.await((error) => errors.push(error)));
		await renderer_renderAsync(`
            import Any from '/test/tmpl/npm/foo-none.mask';
            Any;
        `);
           
        notEq_(errors.length, 0);
        var error = errors[0];
        has_(error.message, 'Module was not resolved');
	}
});

开发者ID:atmajs,项目名称:MaskJS,代码行数:29,代码来源:npm.spec.ts


示例3: eq_

			eq_(result, 'foo');
		},
		async 'should run getter on ASYNC statement' () {

			var someFn = assert.await(async function(){
				return { foo: 'Foo'};
			})

			var ast = expression_parse('(await someFn()).foo');
			var result =  await expression_eval(ast, { someFn });
			eq_(result, 'Foo');
		},		
	},
	'function calls': {
		'should log error for undefined function call' () {
			listeners_on('error', assert.await(error => has_(error.message, 'is not a function')));
			var result =  expression_eval('someFn()');
			eq_(result, null);
			listeners_off('error')
		},
		async 'should evaluate async in fn arguments' () {

			var model = { 
				async someFn () {
					return { foo: 'FoO'}
				},
				toLowerCase (str) {
					return str.toLowerCase()
				}
			};
			var result =  await expression_eval('toLowerCase((await someFn()).foo)', model);
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:expressions-async.spec.ts


示例4: run

				'foo .bar . gaz',
				'foo?.bar?.gaz',
				'foo ?.bar ?. gaz'				
			]
			.forEach(x => {
				var result = run(x, { foo: { bar: { gaz: 'abc' }} });
				eq_(result, 'abc');
			})
		}
	},
	'elvis opearotr': {
		$teardown () {            
			listeners_off('warn');
		},
		'should silently return null' () {
			listeners_on('warn', assert.avoid());
			var x = run('foo?.bar.gaz', { });
			eq_(x, null);
		},
		'should drop warning' () {
			listeners_on('warn', assert.await(msg => {
                has_(msg.message, 'foo.bar.gaz');
			}));
			var x = run('foo.bar.gaz', { });
			eq_(x, null);
		}
	},
	'Or Statements': {
		'Should return last empty string, though it is falsy' () {
			eq_(run('null || ""'), '');		
		},
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:eval.spec.ts


示例5: UTest

import { listeners_off, listeners_on } from '@core/util/listeners';
import { parser_parse, mask_stringify } from '@core/parser/exports';
import { Dom } from '@core/dom/exports';

UTest({
    'should parse properties' () {
        listeners_off('warn');
        listeners_on('warn', assert.avoid());
        listeners_off('error');
        listeners_on('error', assert.avoid());

        [
            `div [ style.baz ] = green;`,
            `div [style.baz ] = green`,
            `div [style.baz]='green'`,
            `div [      style.baz
            ]
                =
            'green'`
        ]
        .forEach(str => {
            var node = parser_parse(str);        
            eq_(node.tagName, 'div');        
            deepEq_(node.props, { 'style.baz': 'green' });
            eq_(node.type, Dom.NODE);

            var back = mask_stringify(node);
            eq_(back, `div [style.baz] = green;`);
        })        
    },
    'should parse properties and other attributes': {
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:props.spec.ts


示例6: find

				find('h4') > text FooFromTmpl;	
			`);
		},
		'let' () {
			'> create owner component'
			var Foo = Compo({});
			customTag_define('Foo', Foo);
			
			'> register from template in the owners scope'
			customTag_registerFromTemplate(`
				let LetBaz {
					h4 > 'LetBaz'
				}
			`, Foo);
			
			listeners_on('error', assert.await(error => has_(error.message, 'LetBaz')));
			var dom = renderer_render(`
				Foo {
					LetBaz;
				}
				LetBaz;
			`);
			listeners_off('error');
			return UTest.domtest(dom, `
				find('h4') {
					length 1;
					text LetBaz;
				}
			`);
		}
	},
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:register.spec.ts


示例7: afterRender

		},

		'should notify unacceptable node' () {
			var template = `
				define Bar {
					var test = true;
					[UpperCase]
					if (this.test) {
						h1 > 'OK'
                    }                    
				}
				Bar;
			`;

			Decorator.define ('UpperCase', {
				afterRender (el) { }
			});

			
			listeners_on('error', assert.await(error => {
				var msg = error.message;
				has_(msg, 'UpperCase');
                has_(msg, 'support');
			}))
			var dom = renderer_render(template);
			return UTest.domtest(dom, `
				find (h1) > text ('OK');
			`)
		}
	}
})
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:decorators.spec.ts


示例8: getLinesOfLast

var errors = [];
var warns  = [];
function getLinesOfLast(arr) {
	var error = (errors.pop() || warns.pop());
	return error.message.split('\n')
}
function getLast(arr?) {
	var error = arr && arr.pop() || (errors.pop() || warns.pop());
	return error.message;
}

UTest({

	$before () {
		listeners_on('error', error => errors.push(error));
		listeners_on('warn', warn => warns.push(warn));
	},
	$after () {
		listeners_off('error');
		listeners_off('warn');
	},
	$teardown () {
		errors = [];
		warns  = [];
	},
	'unexpect tag closing': {
		'starting' () {
			parser_parse('} what');
			var lines = getLinesOfLast(warns);
			has_(lines, [
开发者ID:atmajs,项目名称:MaskJS,代码行数:30,代码来源:parse-errors.spec.ts


示例9: find

				find('h1') > text MyHeader;
			`);
		}
	},
	'scoped (let)': {
		'should create nested scoped component' () {
			var tmpl = `
				define FooGlobal {
					let BarLocal {
						span > 'Bar'
					}
				}
				FooGlobal {
					BarLocal;
				}
				
				BarLocal;
            `;
            
			listeners_on('error', assert.await(err => has_(String(err), 'BarLocal')));
			$(renderer_render(tmpl))
				.eq_('length', 1)
				.eq_('prop', 'tagName', 'SPAN')
				.eq_('text', 'Bar')
				;
            listeners_off('error');
		}
	}
})

// vim: set ft=js:
开发者ID:atmajs,项目名称:MaskJS,代码行数:31,代码来源:define.spec.ts



注:本文中的@core/util/listeners.listeners_on函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript path.path_combine函数代码示例发布时间:2022-05-28
下一篇:
TypeScript listeners.listeners_off函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap