本文整理汇总了TypeScript中rxjs/operators.startWith函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startWith函数的具体用法?TypeScript startWith怎么用?TypeScript startWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startWith函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: initialize
public initialize() {
return {
view: {
base: this.intent.test().pipe(
scan((acc, next: any) => acc + 1, 1),
share(),
startWith(1),
),
test: this.intent.test().pipe(
scan((acc, next: any) => acc + 1, 1),
share(),
startWith(1),
),
test2: this.subject.pipe(
map(({ type, payload, states }) => {
switch (type) {
case 'subject-test':
return payload + states.test2;
default:
return payload;
}
}),
startWith(1),
),
},
};
}
开发者ID:brn,项目名称:react-mvi,代码行数:27,代码来源:factory.spec.ts
示例2: it
it('should convert observable obeject to ordinal object', done => {
const aValue = new Subject();
const bValue = new Subject();
const BUFFER_COUNT = 4;
const values = createObject(
aValue.pipe(startWith('')),
bValue.pipe(startWith('')),
);
subscription.add(
combineTemplate(values)
.pipe(bufferCount(BUFFER_COUNT))
.subscribe(v => {
/*tslint:disable:no-magic-numbers*/
expect(v[0]).to.be.deep.eq(createObject('', ''));
expect(v[1]).to.be.deep.eq(createObject('200', ''));
expect(v[2]).to.be.deep.eq(createObject('200', '300'));
expect(v[3]).to.be.deep.eq(createObject('OK', '300'));
/*tslint:enable:no-magic-numbers*/
done();
}),
);
aValue.next('200');
bValue.next('300');
aValue.next('OK');
});
开发者ID:brn,项目名称:react-mvi,代码行数:28,代码来源:combine-template.spec.ts
示例3: getRecentApps
/**
* Creates an observable list of recently opened apps
* @param {number} max
* @returns {Observable<any[]>}
*/
getRecentApps(max = 20): Observable<RecentAppTab[]> {
return combineLatest(
this.localRepository.getRecentApps().pipe(
startWith([])
),
this.platformRepository.getRecentApps().pipe(
map(apps => apps || []),
startWith([])
), (localApps, platformApps) => [...localApps, ...platformApps].sort((a, b) => b.time - a.time).slice(0, max)
);
}
开发者ID:hmenager,项目名称:composer,代码行数:16,代码来源:new-file-tab.service.ts
示例4: sampleObservable
export function sampleObservable(obs: Observable<any>, scheduler?: any) {
return obs.pipe(
sampleTime(100, scheduler),
share(),
startWith('')
);
}
开发者ID:tjoskar,项目名称:ng2-lazyload-image,代码行数:7,代码来源:scroll-listener.ts
示例5: isErrorLike
cascade =>
isErrorLike(cascade.final)
? [cascade.final]
: queryConfiguredExtensions({ queryGraphQL }, cascade).pipe(
catchError(error => [asError(error) as ErrorLike]),
startWith(LOADING)
)
开发者ID:JoYiRis,项目名称:sourcegraph,代码行数:7,代码来源:helpers.ts
示例6: app
return Object.keys(apps).reduce((states, key) => {
const app = apps[key];
const nextState = app(subject, initialState[key]);
if (nextState.view) {
if (!isObservable(nextState.view)) {
throw new Error(`Application view of ${key} must be Observable.`);
}
nextState.view = nextState.view.pipe(startWith(initialState[key]));
if (!states.view) {
states.view = {};
}
if (!isDefined(states.view[key])) {
states.view[key] = nextState.view;
} else {
states.view[key] = merge(states.view[key], nextState.view);
}
}
for (const key in nextState) {
if (key !== 'view') {
if (!nextState[key] || !(nextState[key] instanceof Observable)) {
throw new Error(`Property ${key} must be Observable.`);
}
if (states[key]) {
states[key] = merge(states[key], nextState[key]);
} else {
states[key] = nextState[key];
}
}
}
return states;
}, states);
开发者ID:brn,项目名称:react-mvi,代码行数:31,代码来源:factory.ts
示例7: addLoadingCount
function addLoadingCount(count$: Observable<number>) {
count$
.pipe(
distinctUntilChanged(),
tap(count => {
if (count < 0) {
throw new Error(
'Observables passed to loadingCount.add() must only emit positive numbers'
);
}
}),
// use takeUntil() so that we can finish each stream on stop() the same way we do when they complete,
// by removing the previous count from the total
takeUntil(stop$),
endWith(0),
startWith(0),
pairwise(),
map(([prev, next]) => next - prev)
)
.subscribe({
next: delta => {
loadingCount$.next(loadingCount$.getValue() + delta);
},
error: error => {
if (fatalErrors) {
fatalErrors.add(error);
}
},
});
}
开发者ID:elastic,项目名称:kibana,代码行数:32,代码来源:http_setup.ts
示例8: ngOnInit
ngOnInit () {
this.playlist$ = this._route.paramMap.pipe(
map(paramMap => ({ playlistId: paramMap.get('id'), playlistOwnerId: paramMap.get('user') })),
switchMap(params =>
this._spotifyService.getPlaylist(params.playlistOwnerId, params.playlistId)
),
map(playlist => ({
isLoading: false,
result: playlist
})),
startWith({
isLoading: true,
result: null
}),
shareReplay()
);
this.tracks$ = this.playlist$.pipe(
filter(o => !o.isLoading && !!o.result),
map(o => o.result.Tracks)
);
this.playlistUrl$ = this.playlist$.pipe(
filter(o => !o.isLoading && !!o.result),
map(o => o.result),
map(playlist => playlist.ImageUrls.length ? playlist.ImageUrls[0] : '')
);
}
开发者ID:Lightw3ight,项目名称:PlayMeExtension,代码行数:28,代码来源:playlist.component.ts
示例9: canExecuteFromNgForm
export function canExecuteFromNgForm(form: AbstractControl | AbstractControlDirective): Observable<boolean> {
return form.statusChanges!.pipe(
startWith(form.valid),
map(() => !!form.valid),
distinctUntilChanged(),
);
}
开发者ID:sketch7,项目名称:ssv-ng2-command,代码行数:7,代码来源:command.util.ts
示例10: app
function app(sources: any): any {
return {
other: sources.other.pipe(
take(1),
startWith('a')
),
};
}
开发者ID:,项目名称:,代码行数:8,代码来源:
注:本文中的rxjs/operators.startWith函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论