本文整理匯總了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]);
});