当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Subject.distinctUntilChanged方法代码示例

本文整理汇总了TypeScript中rxjs/Subject.Subject.distinctUntilChanged方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject.distinctUntilChanged方法的具体用法?TypeScript Subject.distinctUntilChanged怎么用?TypeScript Subject.distinctUntilChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rxjs/Subject.Subject的用法示例。


在下文中一共展示了Subject.distinctUntilChanged方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 constructor(private _functionsService: FunctionsService,
             private _broadcastService: IBroadcastService) {
     this.functionStatusOptions = [
         {
             displayLabel: 'Enabled',
             value: false
         }, {
             displayLabel: 'Disabled',
             value: true
         }];
     this.valueChange = new Subject<boolean>();
     this.valueChange
         .distinctUntilChanged()
         .debounceTime<boolean>(500)
         .switchMap<FunctionInfo>(state => {
             this.selectedFunction.config.disabled = state;
             return this._functionsService.updateFunction(this.selectedFunction);
         })
         .subscribe(fi => this.selectedFunction.config.disabled = fi.config.disabled);
 }
开发者ID:CedarLogic,项目名称:WebJobsPortal,代码行数:20,代码来源:function-configure.component.ts

示例2: constructor

    constructor(private _functionsService: FunctionsService) {
        this.isCode = true;
        this.functionSelectStream = new Subject<FunctionInfo>();
        this.functionSelectStream
            .distinctUntilChanged()
            .switchMap(fi =>
                Observable.zip(
                    this._functionsService.getFileContent(fi.script_href),
                    fi.clientOnly ? Observable.of({}) : this._functionsService.getSecrets(fi),
                    this._functionsService.getFunction(fi),
                    (c, s, f) => ({ content: c, secrets: s, functionInfo: f }))
            )
            .subscribe((res: any) => {
                this.functionInfo = res.functionInfo;
                var fileName = this.functionInfo.script_href.substring(this.functionInfo.script_href.lastIndexOf('/') + 1);
                this.fileName = fileName;
                this.scriptFile = { href: this.functionInfo.script_href, name: fileName };
                this.content = res.content;

                this.configContent = JSON.stringify(this.functionInfo.config, undefined, 2);
                var inputBinding = (this.functionInfo.config && this.functionInfo.config.bindings
                    ? this.functionInfo.config.bindings.find(e => !!e.webHookType)
                    : null);
                if (inputBinding) {
                    this.webHookType = inputBinding.webHookType;
                } else {
                    delete this.webHookType;
                }
                inputBinding = (this.functionInfo.config && this.functionInfo.config.bindings
                    ? this.functionInfo.config.bindings.find(e => e.type === 'httpTrigger')
                    : null);
                if (inputBinding) {
                    this.isHttpFunction = true;
                } else {
                    this.isHttpFunction = false;
                }
                this.createSecretIfNeeded(res.functionInfo, res.secrets);
            });

    }
开发者ID:CedarLogic,项目名称:WebJobsPortal,代码行数:40,代码来源:function-dev.component.ts

示例3: getPlatformMatching

} from './destiny-account.service';
import '../rx-operators';
import { SyncService } from '../storage/sync.service';
import { getBungieAccounts } from './bungie-account.service';
import * as actions from './actions';
import store from '../store/store';
import { loadingTracker } from '../ngimport-more';
import { update } from '../inventory/actions';

let _platforms: DestinyAccount[] = [];
let _active: DestinyAccount | null = null;

// Set the active platform here - it'll drive the other observable
const activePlatform$ = new Subject<DestinyAccount>();

const current$: ConnectableObservable<DestinyAccount | null> = activePlatform$
  .distinctUntilChanged(compareAccounts)
  .do(saveActivePlatform)
  .publishReplay(1);

export function getPlatformMatching(params: Partial<DestinyAccount>): DestinyAccount | undefined {
  return _.find(_platforms, params);
}

// TODO: return a list of bungie accounts and associated destiny accounts?
export function getPlatforms(): IPromise<DestinyAccount[]> {
  if (_platforms.length) {
    return $q.resolve(_platforms);
  }

  // TODO: wire this up with observables?
  const promise = getBungieAccounts()
开发者ID:bhollis,项目名称:DIM,代码行数:32,代码来源:platform.service.ts

示例4: Subject

   * The date the most recently played character was last played.
   */
  readonly lastPlayedDate: Date;
}
// A subject that keeps track of the current account. Because it's a
// behavior subject, any new subscriber will always see its last
// value.
const accountStream: Subject<DestinyAccount> = new ReplaySubject<DestinyAccount>(1);

// The triggering observable for force-reloading progress.
const forceReloadTrigger = new Subject();

// A stream of progress that switches on account changes and supports reloading.
// This is a ConnectableObservable that must be connected to start.
const progressStream: ConnectableObservable<ProgressProfile> = accountStream
      // Only emit when the account changes
      .distinctUntilChanged(compareAccounts)
      // But also re-emit the current value of the account stream
      // whenever the force reload triggers
      .merge(forceReloadTrigger.switchMap(() => accountStream.take(1)))
      // Whenever either trigger happens, load progress
      .switchMap(loadProgress)
      .filter(Boolean)
      // Keep track of the last value for new subscribers
      .publishReplay(1);

/**
 * Set the current account, and get a stream of progress updates.
 * This will keep returning progress even if something else changes
 * the account by also calling "progressStream". This won't force the
 * progress to reload unless they haven't been loaded at all.
开发者ID:delphiactual,项目名称:DIM,代码行数:31,代码来源:progress.service.ts


注:本文中的rxjs/Subject.Subject.distinctUntilChanged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。