本文整理汇总了TypeScript中rxjs.pipe函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pipe函数的具体用法?TypeScript pipe怎么用?TypeScript pipe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pipe函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should return Observable<{}> when T cannot be inferred', () => {
const customOperator = <T>() => (a: Observable<T>) => a;
// type can't be possibly be inferred here, so it's {} instead of T.
const staticPipe = pipe(customOperator());
const o = of('foo').pipe(staticPipe); // $ExpectType Observable<{}>
});
示例2: it
it('should return a noop if not passed a function', () => {
const c = pipe();
expect(c('whatever')).to.equal('whatever');
const someObj = {};
expect(c(someObj)).to.equal(someObj);
});
示例3: validateFormLabels
export function validateFormLabels(jobSpec: JobSpec): FormError[] {
const labels = (jobSpec.job.labels || []).map(([k]) => k);
const message = i18nMark("Cannot have multiple labels with the same key.");
return pipe(
allUniq(_ => "job.labels", [labels], message),
isUniqIn(labels)(i => `job.labels.${i}`, labels, message)
)([]);
}
示例4: backoff
function backoff(maxTries, ms) {
return pipe(
retryWhen(attempts => zip(range(1, maxTries), attempts)
.pipe(
map(([i]) => i * i),
mergeMap(i => timer(i * ms))
)
)
);
}
示例5: backoff
function backoff(maxTries, ms) {
return pipe(
retryWhen(attempts => range(1, maxTries)
.pipe(
zip(attempts, (i) => i),
map(i => i * i),
mergeMap(i => timer(i * ms))
)
)
);
}
示例6: create
async create(fileChanges: VcsFileChange[]): Promise<VcsItemCreateResult<NoteVcsItemComponent>> {
const usedFileChanges: VcsFileChange[] = [];
const refs: VcsItemRef<NoteVcsItemComponent>[] = [];
// Get notes first.
const notes = await toPromise(this.store.pipe(
select(state => state.note.collection.notes),
pipe(take(1)),
));
for (const note of notes) {
let index: number;
const willUseFileChanges: VcsFileChange[] = [];
// Note file
index = fileChanges.findIndex(change => change.absoluteFilePath === note.filePath);
if (index !== -1) {
willUseFileChanges.push(fileChanges[index]);
}
// Note content file
index = fileChanges.findIndex(change => change.absoluteFilePath === note.contentFilePath);
if (index !== -1) {
willUseFileChanges.push(fileChanges[index]);
}
if (willUseFileChanges.length > 0) {
const config: VcsItemConfig = {
title: note.title,
fileChanges: willUseFileChanges,
};
const ref = new VcsItemRef<NoteVcsItemComponent>(config);
ref.component = NoteVcsItemComponent;
usedFileChanges.push(...willUseFileChanges);
refs.push(ref);
}
}
return { refs, usedFileChanges };
}