本文整理汇总了TypeScript中lodash.defer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defer函数的具体用法?TypeScript defer怎么用?TypeScript defer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了defer函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: promiseError
export function promiseError( msg: string, resName : string, errcode: number = 500 ) : Q.Promise< relaxjs.Embodiment > {
var later = Q.defer< relaxjs.Embodiment >();
_.defer( () => {
_log.error(msg);
later.reject( emitError( msg, resName, errcode ) )
});
return later.promise;
}
开发者ID:micurs,项目名称:relaxjs,代码行数:8,代码来源:internals.ts
示例2: function
then: function (success_callback: Function, failure_callback: Function) {
if (trigger_callback === "done") {
_.defer(() => {
success_callback(...args!);
// options.____test_done();
});
}
if (trigger_callback === "fail") {
_.defer(() => {
failure_callback(...args!);
});
}
// return ajax_stub;
},
开发者ID:AJamesPhillips,项目名称:napthr,代码行数:18,代码来源:ajax.ts
示例3: function
}, function (xhr, textStatus) {
const action = {
type: failure_action,
status_code: xhr.status,
status_text: xhr.statusText,
response: JSON.parse(xhr.responseText || "{\"error\":\"no xhr.responseText\"}"),
};
dispatch(action);
_.defer(reject);
});
开发者ID:AJamesPhillips,项目名称:napthr,代码行数:11,代码来源:store_util.ts
示例4: redirect
export function redirect( location: string ) : Q.Promise< relaxjs.Embodiment > {
var later = Q.defer< relaxjs.Embodiment >();
_.defer( () => {
_log.info('Sending a Redirect 307 towards %s',location );
var redir = new relaxjs.Embodiment('text/html');
redir.httpCode = 307; // Temporary Redirect (since HTTP/1.1)
redir.location = location;
later.resolve(redir);
});
return later.promise;
}
开发者ID:micurs,项目名称:relaxjs,代码行数:11,代码来源:internals.ts
示例5: it
it('must give status', () => {
defer(() => {
server.checkalivestatus();
server.checkalivestatus();
});
return server.status
.delay(1)
.take(1)
.toPromise();
});
开发者ID:OmniSharp,项目名称:omnisharp-node-client,代码行数:11,代码来源:omnisharp-client-spec.ts
示例6: complete
private complete(event: Event, char: string) {
var editor = atom.workspace.getActiveTextEditor();
if (editor) {
var view = atom.views.getView(editor);
atom.commands.dispatch(atom.views.getView(editor), 'autocomplete-plus:confirm');
defer(() => editor.insertText(char));
event.preventDefault();
event.stopImmediatePropagation();
event.stopPropagation();
return false;
}
}
开发者ID:AndersNS,项目名称:omnisharp-atom,代码行数:13,代码来源:intellisense.ts
示例7: dispatch
.then(function (response_data, text_status) {
if (_.isString(success_action)) {
const action = {
type: success_action,
response: response_data,
};
dispatch(action);
}
else {
success_action(response_data, text_status);
}
_.defer(resolve);
}, function (xhr, textStatus) {
开发者ID:AJamesPhillips,项目名称:napthr,代码行数:15,代码来源:store_util.ts
示例8: createEmbodiment
export function createEmbodiment( viewData: any, mimeType: string ) : Q.Promise< relaxjs.Embodiment > {
var log = _log.child( { func: 'internals.viewJson'} );
var later = Q.defer< relaxjs.Embodiment >();
var resourceName = 'resource';
log.info('Creating Embodiment as %s',mimeType);
_.defer( () => {
try {
// 1 Copy the public properties and _name to a destination object for serialization.
var destObj = {};
_.each( _.keys( viewData) , function(key: string) {
//
if ( key === '_name' ) {
destObj['name'] = viewData[key];
resourceName = viewData[key];
}
else if ( key.indexOf('_') === 0 )
return;
else {
//console.log('['+key+'] is '+viewData[key] );
destObj[key] = viewData[key];
}
});
// 2 - build the embodiment serializing the data as a Buffer
// log.info('Serializing "%s"',JSON.stringify(destObj));
var dataString = '';
switch(mimeType) {
case 'application/xml':
case 'text/xml':
var builder = new xml2js.Builder({ rootName: resourceName, renderOpts : { 'pretty': false }, headless: true });
dataString = builder.buildObject( destObj );
break;
default:
dataString = JSON.stringify( destObj );
break;
}
// log.info('Delivering: "%s"',dataString);
var e = new relaxjs.Embodiment( mimeType, 200, new Buffer( dataString,'utf-8' ) );
later.resolve( e );
}
catch( err ) {
log.error(err);
later.reject( new relaxjs.RxError('JSON Serialization error: '+err ) )
}
});
return later.promise;
}
开发者ID:micurs,项目名称:relaxjs,代码行数:46,代码来源:internals.ts
注:本文中的lodash.defer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论