本文整理汇总了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);
}
示例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);
});
}
示例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()
示例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.