當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript operators.distinctUntilChanged函數代碼示例

本文整理匯總了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
});
開發者ID:BobChao87,項目名稱:angular,代碼行數:17,代碼來源:typeahead.ts

示例2: select

 select(selector: any): Observable<any> {
     return this.state$.pipe(
         map(selector),
         distinctUntilChanged()
     );
 }
開發者ID:whyour,項目名稱:ngx-tethys,代碼行數:6,代碼來源:store.ts

示例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,
開發者ID:JoYiRis,項目名稱:sourcegraph,代碼行數:31,代碼來源:settings.ts

示例4: constructor

 constructor(public notificationBarService: NotificationBarService, public cdr: ChangeDetectorRef) {
     super();
     this.notificationBarService.displayedNotifications.pipe(
         distinctUntilChanged()
     ).subscribeTracked(this, notifications => this.notifications = notifications);
 }
開發者ID:hmenager,項目名稱:composer,代碼行數:6,代碼來源:notification-bar.component.ts

示例5: distinctUntilChanged

 select<R>(mapFn: (state: T) => R) {
   return this.pipe(map(mapFn), distinctUntilChanged());
 }
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:3,代碼來源:store.ts

示例6: it

it('should infer correctly', () => {
  const o = of(sample).pipe(distinctUntilChanged()); // $ExpectType Observable<Person>
});
開發者ID:jaychsu,項目名稱:RxJS,代碼行數:3,代碼來源:distinctUntilChanged-spec.ts

示例7: function

 return function(source$) {
     return source$.pipe(
         map(state => selector(state)),
         distinctUntilChanged(),
     )
 }
開發者ID:zodiac-team,項目名稱:zodiac-ui,代碼行數:6,代碼來源:operators.ts


注:本文中的rxjs/operators.distinctUntilChanged函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。