本文整理汇总了TypeScript中rxjs/Rx.BehaviorSubject类的典型用法代码示例。如果您正苦于以下问题:TypeScript BehaviorSubject类的具体用法?TypeScript BehaviorSubject怎么用?TypeScript BehaviorSubject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BehaviorSubject类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: PresentationOnBreakpoint
export function PresentationOnBreakpoint(
breakpoints: {
breakpoint: number;
presentation: GridBodyPresentation
}[]
): BehaviorSubject<GridBodyPresentation> {
function getPresentation() {
var width = window.outerWidth, i = 0;
while (i < breakpoints.length - 1 && breakpoints[i + 1].breakpoint < width) {
i++;
}
return breakpoints[i].presentation;
}
breakpoints.sort((a, b) => a.breakpoint - b.breakpoint);
let subject = new BehaviorSubject<GridBodyPresentation>(getPresentation());
function listener() {
subject.next(getPresentation());
}
subject.next(getPresentation());
window.addEventListener('resize', listener);
return subject;
}
开发者ID:Azure,项目名称:azure-iot-library,代码行数:31,代码来源:grid.presentation.ts
示例2: constructor
constructor(private _data:DataService, private _user:UserService, private _cd:ChangeDetectorRef) {
this.isAuth = new BehaviorSubject(false);
this.privateData = new BehaviorSubject('');
this.isAuth.subscribe(val => this.authStatus = val);
this.privateData.subscribe(val => this.message = val);
}
开发者ID:colinjlacy,项目名称:firebase-ionic-2-demo,代码行数:7,代码来源:auth.ts
示例3: constructor
constructor () {
let windowSize$ = new BehaviorSubject(this.newWindowSize());
this.windowObject$ = windowSize$.distinctUntilChanged();
Observable.fromEvent(window, 'resize')
.map(this.newWindowSize)
.subscribe(windowSize$);
}
开发者ID:spencersmb,项目名称:ng2-material-intro,代码行数:9,代码来源:device.ts
示例4: it
it('if not passed any rows, does nothing', (done) => {
var selection = new BehaviorSubject<{[key: string]: string}>({});
var doOnce = false;
selection.subscribe(() => {
if (!doOnce) {
doOnce = true;
} else {
done.fail('Changed the selection');
}
});
SelectionUpdateStrategies.SimpleIteration(selection, null, d => d.id);
setTimeout(done);
});
开发者ID:Azure,项目名称:azure-iot-library,代码行数:14,代码来源:grid.source.spec.ts
示例5:
this.document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") {
this.detailedFocusSubject.next(DetailedFocusStates.TabFocus);
} else {
this.detailedFocusSubject.next(DetailedFocusStates.TabBlur);
}
});
开发者ID:sstorie,项目名称:experiments,代码行数:7,代码来源:window-focus.service.ts
示例6:
(counties: County[]) => {
if (!this._counties$.getValue().length) {
counties.forEach((county: County) =>
this._counties$.getValue().push(county));
}
this._counties$.next(this._counties$.getValue());
},
开发者ID:praetorxyn,项目名称:angular2-interactive-map,代码行数:7,代码来源:county.service.ts
示例7:
this.autobahn.onclose((reason, details) => {
log.error(`Connection lost, reason: [${reason}]`)
log.error(`Connection lost, details: [${JSON.stringify(details)}]`)
this.isConnected = false
const disconnectTimerDisposable = this.autoDisconnectDisposable
if (disconnectTimerDisposable) {
disconnectTimerDisposable.unsubscribe()
}
// if we explicitly called close then we move to ConnectionStatus.idle status
if (reason === 'closed') {
this.connectionStatusSubject.next(ConnectionStatus.sessionExpired)
} else {
this.connectionStatusSubject.next(ConnectionStatus.disconnected)
}
})
开发者ID:tdeheurles,项目名称:ReactiveTraderCloud,代码行数:15,代码来源:connection.ts
示例8:
ref.child(key).on('value', snapshot => {
if (snapshot.exists()) {
let model = snapshot.val();
model.$key = snapshot.key;
return model$.next(model);
}
});
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:7,代码来源:firebase-helper.ts
示例9:
this._user.auth.onAuthStateChanged(user => {
this.isAuth.next(!!user);
this._cd.detectChanges();
this._data.db.child('/private').on('value', data => {
this.privateData.next(data.val());
this._cd.detectChanges();
}, err => console.log(err));
});
开发者ID:colinjlacy,项目名称:firebase-ionic-2-demo,代码行数:8,代码来源:auth.ts
注:本文中的rxjs/Rx.BehaviorSubject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论