本文整理匯總了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 };
}