本文整理汇总了TypeScript中rxjs/Subject.Subject.next方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Subject.next方法的具体用法?TypeScript Subject.next怎么用?TypeScript Subject.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxjs/Subject.Subject
的用法示例。
在下文中一共展示了Subject.next方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
message: (message) => {
console.debug('Received from server the following : ', message['data']['data']);
const communication: ServerCommunication = message['data']['data'];
switch(communication['type']){
case 'question':
this._questions.next(communication);
break;
case 'notification':
console.log('received a notif');
this._notifs.next(communication);
break;
case 'scores':
this._scores.next(communication['content']);
break;
case 'complete':
this._questions.complete();
break;
default:
console.log('Type of the communication unknown');
break;
}
},
示例2: inject
inject([Overlay], (overlay: Overlay) => {
overlayRef.dispose();
scrollPosition = 100;
overlayRef = overlay.create({
scrollStrategy: overlay.scrollStrategies.close({threshold: 50})
});
overlayRef.attach(componentPortal);
spyOn(overlayRef, 'updatePosition');
spyOn(overlayRef, 'detach');
// Scroll down 30px.
for (let i = 0; i < 30; i++) {
scrollPosition++;
scrolledSubject.next();
}
// Scroll back up 30px.
for (let i = 0; i < 30; i++) {
scrollPosition--;
scrolledSubject.next();
}
expect(overlayRef.updatePosition).toHaveBeenCalledTimes(60);
expect(overlayRef.detach).not.toHaveBeenCalled();
}));
示例3: xit
xit('Should display notification about cached content only once', () => {
localStorage.clear();
activated.next({current: {hash: 'asdf'}} as UpdateActivatedEvent);
activated.next({current: {hash: 'asdf'}} as UpdateActivatedEvent);
expect(snackBarServiceStub.displayNotification.called).toBe(true, 'Notification was not displayed');
expect(snackBarServiceStub.displayNotification.calledOnce).toBe(true, 'Notification was not displayed once');
});
示例4: it
it ('Check collapsed', () => {
userSettingState = UserSettingUtil.updateUserSettingState(userSettingState, mutable => {
mutable.swimlane = 'component';
mutable.defaultCollapsedSwimlane = false;
mutable.collapsedSwimlanes = Map<string, boolean>({'a': true, 'b': true, 'c': true, 'd': false});
});
userSettingSubject.next(userSettingState);
urlObservable
.pipe(
take(1)
)
.subscribe(s => {
expect(s).toContain('hidden-sl=a,b,c');
expect(s).not.toContain('visible-sl');
});
userSettingState = UserSettingUtil.updateUserSettingState(userSettingState, mutable => {
mutable.swimlane = 'component';
mutable.defaultCollapsedSwimlane = true;
mutable.collapsedSwimlanes = Map<string, boolean>({'a': false, 'b': false, 'c': false, 'd': true});
});
userSettingSubject.next(userSettingState);
urlObservable
.pipe(
take(1)
)
.subscribe(s => {
expect(s).toContain('visible-sl=a,b,c');
expect(s).not.toContain('hidden-sl');
});
})
示例5: test
test("Gives the latest options when options are changed", () => {
let changingConfig = "omnisharp";
updateConfig(vscode, changingConfig, 'path', "somePath");
optionObservable.next(Options.Read(vscode));
updateConfig(vscode, changingConfig, 'path', "anotherPath");
optionObservable.next(Options.Read(vscode));
let options = optionProvider.GetLatestOptions();
expect(options.path).to.be.equal("anotherPath");
});
示例6: it
it('should update the overlay position when the page is scrolled', () => {
overlayRef.attach(componentPortal);
spyOn(overlayRef, 'updatePosition');
scrolledSubject.next();
expect(overlayRef.updatePosition).toHaveBeenCalledTimes(1);
scrolledSubject.next();
expect(overlayRef.updatePosition).toHaveBeenCalledTimes(2);
});
示例7: it
it('should create a new todo', () => {
const actions = new Subject<Action>();
const states = stateFn({ todos: [], visibilityFilter: 'SHOW_ALL' }, actions);
actions.next(new AddTodoAction(100, 'todo1'));
actions.next(new AddTodoAction(101, 'todo2'));
states.subscribe(s => {
expect(s.todos.length).toEqual(2);
expect(s.todos[0]).toEqual({ id: 100, text: 'todo1', completed: false });
expect(s.todos[1]).toEqual({ id: 101, text: 'todo2', completed: false });
});
});
示例8: it
it('should work', () => {
const subject = new Subject<number>();
const log: number[] = [];
subject.map(x => 2 * x + 1)
.subscribe(next => log.push(next));
subject.next(2);
expect(log).toEqual([5]);
subject.next(3);
expect(log).toEqual([5, 7]);
});