本文整理汇总了TypeScript中boa-core.O类的典型用法代码示例。如果您正苦于以下问题:TypeScript O类的具体用法?TypeScript O怎么用?TypeScript O使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了O类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: dispatch
const handler = (action$: O<A<any>>, options: any): O<A<any>> => {
const is = (action: A<any>): boolean => action.type === typeT;
const other$: O<A<any>> = action$
.filter(action => !is(action));
const target$: O<A<T>> = action$
.filter(is);
const result$: O<A<U>> = dispatch(target$)
.filter(a => !!a)
.share();
return O.merge(result$, other$);
};
示例2: return
return (action$: O<A<any>>, _: any): O<A<any>> => {
return O.merge(
action$,
action$.first().map(() => {
runServer(serverOptions, expressHandler);
return; // return undefined
})
)
.filter(a => !!a) // remove undefined
.share();
};
示例3: test
test(t => {
t.plan(3);
const init: typeof initType = t.context.init;
const History: sinon.SinonStub = t.context.History;
const go: sinon.SinonStub = t.context.go;
const start: sinon.SinonStub = t.context.start;
const routes: Route[] = [];
const action$ = O.of({ type: 'foo' }); // ignore
const options = { re: (): any => null };
init({ routes }).handler(action$, options).subscribe();
t.truthy(History.callCount === 1);
t.truthy(start.callCount === 1);
t.truthy(go.callCount === 0);
});
示例4:
const dispatch = (action$: O<A<T>>): O<A<U>> => {
return action$
.map(({ data }) => fs[data.name](data.params))
.map(data => ({ type: typeU, data }));
};