fix(xxx-intl): replace misused EventEmitter with Subject (#6313)

* fix(xxx-intl): replace misused EventEmitter with Subject

According to https://angular.io/api/core/EventEmitter#description, EventEmitter is not for services. And Subject is preferrable.

* test(xxx-intl): update the related tests

* refactor: remove spaces
This commit is contained in:
Scott
2017-08-09 04:21:52 +08:00
committed by mmalerba
parent 5ebca5ee81
commit c20bcf997a
7 changed files with 13 additions and 10 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ describe('MdCalendar', () => {
.querySelector('.mat-calendar-period-button');
intl.switchToYearViewLabel = 'Go to year view?';
intl.changes.emit();
intl.changes.next();
fixture.detectChanges();
expect(button.getAttribute('aria-label')).toBe('Go to year view?');
+3 -2
View File
@@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable, EventEmitter} from '@angular/core';
import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Subject';
/** Datepicker data that requires internationalization. */
@@ -16,7 +17,7 @@ export class MdDatepickerIntl {
* Stream that emits whenever the labels here are changed. Use this to notify
* components if the labels have changed after initialization.
*/
changes: EventEmitter<void> = new EventEmitter<void>();
changes: Subject<void> = new Subject<void>();
/** A label for the calendar popup (used by screen readers). */
calendarLabel = 'Calendar';
+1 -1
View File
@@ -571,7 +571,7 @@ describe('MdDatepicker', () => {
const toggle = fixture.debugElement.query(By.css('button')).nativeElement;
intl.openCalendarLabel = 'Open the calendar, perhaps?';
intl.changes.emit();
intl.changes.next();
fixture.detectChanges();
expect(toggle.getAttribute('aria-label')).toBe('Open the calendar, perhaps?');
+3 -2
View File
@@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable, EventEmitter} from '@angular/core';
import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Subject';
/**
* To modify the labels and text displayed, create a new instance of MdPaginatorIntl and
@@ -18,7 +19,7 @@ export class MdPaginatorIntl {
* Stream that emits whenever the labels here are changed. Use this to notify
* components if the labels have changed after initialization.
*/
changes: EventEmitter<void> = new EventEmitter<void>();
changes: Subject<void> = new Subject<void>();
/** A label for the page size selector. */
itemsPerPageLabel = 'Items per page:';
+1 -1
View File
@@ -96,7 +96,7 @@ describe('MdPaginator', () => {
const label = fixture.nativeElement.querySelector('.mat-paginator-page-size-label');
intl.itemsPerPageLabel = '1337 items per page';
intl.changes.emit();
intl.changes.next();
fixture.detectChanges();
expect(label.textContent).toBe('1337 items per page');
+3 -2
View File
@@ -6,7 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Injectable, EventEmitter} from '@angular/core';
import {Injectable} from '@angular/core';
import {Subject} from 'rxjs/Subject';
import {SortDirection} from './sort-direction';
/**
@@ -19,7 +20,7 @@ export class MdSortHeaderIntl {
* Stream that emits whenever the labels here are changed. Use this to notify
* components if the labels have changed after initialization.
*/
changes: EventEmitter<void> = new EventEmitter<void>();
changes: Subject<void> = new Subject<void>();
/** ARIA label for the sorting button. */
sortButtonLabel = (id: string) => {
+1 -1
View File
@@ -148,7 +148,7 @@ describe('MdSort', () => {
const button = header.querySelector('.mat-sort-header-button');
intl.sortButtonLabel = () => 'Sort all of the things';
intl.changes.emit();
intl.changes.next();
fixture.detectChanges();
expect(button.getAttribute('aria-label')).toBe('Sort all of the things');