本文整理汇总了TypeScript中fibers类的典型用法代码示例。如果您正苦于以下问题:TypeScript fibers类的具体用法?TypeScript fibers怎么用?TypeScript fibers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fibers类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _exec
/** */
_exec( args, done: ( err: boolean ) => void ) {
try {
const fn = fibers( () => this.exec( args, done ) );
fn.run();
} catch ( err ) {
if ( err )
this.error( "Throwed error:" + err.toString() );
done( true );
}
}
示例2: require
// this call must be first to avoid requiring c++ dependencies
require("./common/verify-node-version").verifyNodeVersion(node, "NativeScript", "2.2.0");
require("./bootstrap");
import * as fiber from "fibers";
import Future = require("fibers/future");
import * as shelljs from "shelljs";
shelljs.config.silent = true;
import {installUncaughtExceptionListener} from "./common/errors";
installUncaughtExceptionListener(process.exit);
fiber(() => {
let config: Config.IConfig = $injector.resolve("$config");
let err: IErrors = $injector.resolve("$errors");
err.printCallStack = config.DEBUG;
let commandDispatcher: ICommandDispatcher = $injector.resolve("commandDispatcher");
let messages: IMessagesService = $injector.resolve("$messagesService");
messages.pathsToMessageJsonFiles = [/* Place client-specific json message file paths here */];
if (process.argv[2] === "completion") {
commandDispatcher.completeCommand().wait();
} else {
commandDispatcher.dispatchCommand().wait();
}
$injector.dispose();
Future.assertNoFutureLeftBehind();
}).run();
示例3: run
export function run(action: any) {
if(fiber.current) {
// Use the already existing fiber, we do not need new one.
action();
} else {
fiber(() => {
action();
// Call dispose method of $injector modules, which implement IDisposable.
$injector.dispose();
Future.assertNoFutureLeftBehind();
}).run();
}
}