本文整理汇总了TypeScript中rxjs/operators.distinctUntilChanged函数的典型用法代码示例。如果您正苦于以下问题:TypeScript distinctUntilChanged函数的具体用法?TypeScript distinctUntilChanged怎么用?TypeScript distinctUntilChanged使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了distinctUntilChanged函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fromEvent
import { fromEvent } from 'rxjs';
import { ajax } from 'rxjs/ajax';
import { map, filter, debounceTime, distinctUntilChanged, switchMap } from 'rxjs/operators';
const searchBox = document.getElementById('search-box');
const typeahead = fromEvent(searchBox, 'input').pipe(
map((e: KeyboardEvent) => e.target.value),
filter(text => text.length > 2),
debounceTime(10),
distinctUntilChanged(),
switchMap(() => ajax('/api/endpoint'))
);
typeahead.subscribe(data => {
// Handle the data from the API
});
示例2: select
select(selector: any): Observable<any> {
return this.state$.pipe(
map(selector),
distinctUntilChanged()
);
}
示例3: combineLatest
* browser extension.
* - For authenticated users, this is just the GraphQL settings (client settings are ignored to simplify the UX).
*/
export const settingsCascade: Observable<SettingsCascadeOrError> = combineLatest(
gqlSettingsCascade,
storageSettingsCascade
).pipe(
map(([gqlCascade, storageCascade]) =>
mergeCascades(
gqlToCascade(gqlCascade),
gqlCascade.subjects.some(subject => subject.__typename === 'User')
? EMPTY_CONFIGURATION_CASCADE
: storageCascade
)
),
distinctUntilChanged((a, b) => isEqual(a, b))
)
/**
* Applies an edit and persists the result to client settings.
*/
export function editClientSettings(args: UpdateExtensionSettingsArgs): Promise<void> {
return new Promise<StorageItems>(resolve => storage.getSync(storageItems => resolve(storageItems))).then(
storageItems => {
let clientSettings = storageItems.clientSettings
const format = { tabSize: 2, insertSpaces: true, eol: '\n' }
if ('edit' in args && args.edit) {
clientSettings = applyEdits(
clientSettings,
示例4: constructor
constructor(public notificationBarService: NotificationBarService, public cdr: ChangeDetectorRef) {
super();
this.notificationBarService.displayedNotifications.pipe(
distinctUntilChanged()
).subscribeTracked(this, notifications => this.notifications = notifications);
}
示例5: distinctUntilChanged
select<R>(mapFn: (state: T) => R) {
return this.pipe(map(mapFn), distinctUntilChanged());
}
示例6: it
it('should infer correctly', () => {
const o = of(sample).pipe(distinctUntilChanged()); // $ExpectType Observable<Person>
});
示例7: function
return function(source$) {
return source$.pipe(
map(state => selector(state)),
distinctUntilChanged(),
)
}