本文整理汇总了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;
});
}