本文整理匯總了TypeScript中@funkia/jabz.go函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript go函數的具體用法?TypeScript go怎麽用?TypeScript go使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了go函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: loop
function loop(n: number): Now<Behavior<number>> {
return go(function*() {
const nextNumber = yield performIO(getNextNr(1));
const future = yield plan(nextNumber.map(loop));
return switchTo(Behavior.of(n), future);
});
}
示例2: it
it("time doesn't pass in a Now", () => {
const now = go(function*() {
const t1 = yield sample(time);
while (Date.now() <= t1) {}
const t2 = yield sample(time);
assert.strictEqual(t1, t2);
});
runNow(now);
});
示例3: it
it("works with go-notation", () => {
const a = H.sinkBehavior(1);
const b = go(function*(): IterableIterator<any> {
const val = yield a;
return val * 2;
});
const cb = spy();
b.subscribe(cb);
a.push(7);
assert.deepEqual(cb.args, [[2], [14]]);
});
示例4: main
function main(): Now<Future<number>> {
return go(function*() {
const b: Behavior<number> = yield loop(0);
const e = yield sample(
whenFrom(
b.map((n: number) => {
return n === 3;
})
)
);
return e;
});
}