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