本文整理匯總了TypeScript中rxjs/operators.concat函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript concat函數的具體用法?TypeScript concat怎麽用?TypeScript concat使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了concat函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should concat if first source emits once, second source is empty', () => {
const e1 = cold('--a--|');
const e1subs = '^ !';
const e2 = cold( '--------|');
const e2subs = ' ^ !';
const expected = '--a----------|';
expectObservable(e1.pipe(concat(e2))).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(e1subs);
expectSubscriptions(e2.subscriptions).toBe(e2subs);
});
示例2: map
return folders.map(path => MyAppsPanelService.makeTreeNode({
id: path,
data: path,
type: "folder",
label: AppHelper.getBasename(path),
isExpanded: this.localExpandedNodes.pipe(
map(list => list.indexOf(path) !== -1)
),
children: empty().pipe(
concat(this.fileRepository.watch(path)),
map(listing => this.createDirectoryListingTreeNodes(listing))
)
}));
示例3: asDiagram
asDiagram('timer(3000, 1000)')('should create an observable emitting periodically', () => {
const e1 = timer(60, 20, rxTestScheduler).pipe(
take(4), // make it actually finite, so it can be rendered
concat(NEVER) // but pretend it's infinite by not completing
);
const expected = '------a-b-c-d-';
const values = {
a: 0,
b: 1,
c: 2,
d: 3,
};
expectObservable(e1).toBe(expected, values);
});
示例4: fetchFileContent
fetchFileContent(almostID: string, parse = false): Observable<string> {
const source = DataGatewayService.getFileSource(almostID);
if (source === "local") {
const fetch = empty().pipe(concat(this.ipc.request("getLocalFileContent", almostID)));
if (parse) {
return fetch.pipe(
map(content => {
try {
return YAML.safeLoad(content, {json: true, onWarning: noop} as any);
} catch (err) {
return new Error(err);
}
})
);
}
return fetch;
}
if (source === "app" || source === "public") {
const fetch = empty().pipe(
concat(this.ipc.request("getPlatformApp", {id: almostID}))
);
if (parse) {
return fetch.pipe(
map(content => JSON.parse(content))
);
}
return fetch;
}
}
示例5: it
it('should retry a synchronous source (multicasted and refCounted) multiple times', (done: MochaDone) => {
const expected = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3];
of(1, 2, 3).pipe(
concat(throwError('bad!')),
multicast(() => new Subject()),
refCount(),
retry(4)
).subscribe(
(x: number) => { expect(x).to.equal(expected.shift()); },
(err: any) => {
expect(err).to.equal('bad!');
expect(expected.length).to.equal(0);
done();
}, () => {
done(new Error('should not be called'));
});
});
示例6: if
return listing.map(fsEntry => {
const id = fsEntry.path;
const label = AppHelper.getBasename(fsEntry.path);
let icon = "fa-folder";
const iconExpanded = "fa-folder-open";
if (fsEntry.type === "Workflow") {
icon = "fa-share-alt";
} else if (fsEntry.type === "CommandLineTool") {
icon = "fa-terminal";
} else if (fsEntry.isFile) {
icon = "fa-file";
}
let children = undefined;
if (fsEntry.isDir) {
children = empty().pipe(
concat(this.ipc.request("readDirectory", fsEntry.path)),
map(list => this.createDirectoryListingTreeNodes(list))
);
}
return MyAppsPanelService.makeTreeNode({
id,
icon,
label,
children,
iconExpanded,
data: fsEntry,
dragLabel: label,
dragDropZones: ["graph-editor", "job-editor"],
isExpandable: fsEntry.isDir,
dragTransferData: {name: fsEntry.path, type: getDragTransferDataType(fsEntry)},
type: fsEntry.isDir ? "folder" : "file",
isExpanded: this.localExpandedNodes.pipe(
map(list => list.indexOf(fsEntry.path) !== -1)
),
dragEnabled: true,
dragImageClass: getDragImageClass(fsEntry)
});
});