本文整理汇总了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;
}
示例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;
},
示例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);
});
示例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;
}
示例5: it
it('must give status', () => {
defer(() => {
server.checkalivestatus();
server.checkalivestatus();
});
return server.status
.delay(1)
.take(1)
.toPromise();
});
示例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;
}
}
示例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) {
示例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;
}