当前位置: 首页>>代码示例>>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;未经允许,请勿转载。