Skip to content

Commit 29caaf3

Browse files
crisbetokara
authored andcommitted
refactor: remove @output privatization (#4199)
Fixes #4188.
1 parent e7326ee commit 29caaf3

File tree

6 files changed

+15
-36
lines changed

6 files changed

+15
-36
lines changed

src/lib/button-toggle/button-toggle.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
160160
}
161161

162162
/** Event emitted when the group's value changes. */
163-
@Output() get change(): Observable<MdButtonToggleChange> {
164-
return this._change.asObservable();
165-
}
166-
private _change: EventEmitter<MdButtonToggleChange> = new EventEmitter<MdButtonToggleChange>();
163+
@Output() change: EventEmitter<MdButtonToggleChange> = new EventEmitter<MdButtonToggleChange>();
167164

168165
private _updateButtonToggleNames(): void {
169166
if (this._buttonToggles) {
@@ -198,7 +195,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
198195
event.source = this._selected;
199196
event.value = this._value;
200197
this._controlValueAccessorChangeFn(event.value);
201-
this._change.emit(event);
198+
this.change.emit(event);
202199
}
203200

204201
/**
@@ -372,10 +369,7 @@ export class MdButtonToggle implements OnInit {
372369
}
373370

374371
/** Event emitted when the group value changes. */
375-
private _change: EventEmitter<MdButtonToggleChange> = new EventEmitter<MdButtonToggleChange>();
376-
@Output() get change(): Observable<MdButtonToggleChange> {
377-
return this._change.asObservable();
378-
}
372+
@Output() change: EventEmitter<MdButtonToggleChange> = new EventEmitter<MdButtonToggleChange>();
379373

380374
constructor(@Optional() toggleGroup: MdButtonToggleGroup,
381375
@Optional() toggleGroupMultiple: MdButtonToggleGroupMultiple,
@@ -460,6 +454,6 @@ export class MdButtonToggle implements OnInit {
460454
let event = new MdButtonToggleChange();
461455
event.source = this;
462456
event.value = this._value;
463-
this._change.emit(event);
457+
this.change.emit(event);
464458
}
465459
}

src/lib/core/style/focus-origin-monitor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,7 @@ export class FocusOriginMonitor {
284284
selector: '[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]',
285285
})
286286
export class CdkMonitorFocus implements OnDestroy {
287-
@Output()
288-
cdkFocusChange = new EventEmitter<FocusOrigin>();
287+
@Output() cdkFocusChange = new EventEmitter<FocusOrigin>();
289288

290289
constructor(private _elementRef: ElementRef, private _focusOriginMonitor: FocusOriginMonitor,
291290
renderer: Renderer) {

src/lib/radio/radio.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ export class MdRadioGroup implements AfterContentInit, ControlValueAccessor {
9595
* Change events are only emitted when the value changes due to user interaction with
9696
* a radio button (the same behavior as `<input type-"radio">`).
9797
*/
98-
@Output()
99-
change: EventEmitter<MdRadioChange> = new EventEmitter<MdRadioChange>();
98+
@Output() change: EventEmitter<MdRadioChange> = new EventEmitter<MdRadioChange>();
10099

101100
/** Child radio buttons. */
102101
@ContentChildren(forwardRef(() => MdRadioButton))
@@ -379,8 +378,7 @@ export class MdRadioButton implements OnInit, AfterViewInit, OnDestroy {
379378
* Change events are only emitted when the value changes due to user interaction with
380379
* the radio button (the same behavior as `<input type-"radio">`).
381380
*/
382-
@Output()
383-
change: EventEmitter<MdRadioChange> = new EventEmitter<MdRadioChange>();
381+
@Output() change: EventEmitter<MdRadioChange> = new EventEmitter<MdRadioChange>();
384382

385383
/** The parent radio group. May or may not be present. */
386384
radioGroup: MdRadioGroup;

src/lib/slide-toggle/slide-toggle.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ export class MdSlideToggle implements OnDestroy, AfterContentInit, ControlValueA
109109
get disableRipple(): boolean { return this._disableRipple; }
110110
set disableRipple(value) { this._disableRipple = coerceBooleanProperty(value); }
111111

112-
private _change: EventEmitter<MdSlideToggleChange> = new EventEmitter<MdSlideToggleChange>();
113112
/** An event will be dispatched each time the slide-toggle changes its value. */
114-
@Output() change: Observable<MdSlideToggleChange> = this._change.asObservable();
113+
@Output() change: EventEmitter<MdSlideToggleChange> = new EventEmitter<MdSlideToggleChange>();
115114

116115
/** Returns the unique id for the visual hidden input. */
117116
get inputId(): string { return `${this.id || this._uniqueId}-input`; }
@@ -262,7 +261,7 @@ export class MdSlideToggle implements OnDestroy, AfterContentInit, ControlValueA
262261
let event = new MdSlideToggleChange();
263262
event.source = this;
264263
event.checked = this.checked;
265-
this._change.emit(event);
264+
this.change.emit(event);
266265
}
267266

268267

src/lib/tabs/tab-body.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,10 @@ export class MdTabBody implements OnInit, AfterViewChecked {
7878
@ViewChild(PortalHostDirective) _portalHost: PortalHostDirective;
7979

8080
/** Event emitted when the tab begins to animate towards the center as the active tab. */
81-
@Output()
82-
onCentering: EventEmitter<number> = new EventEmitter<number>();
81+
@Output() onCentering: EventEmitter<number> = new EventEmitter<number>();
8382

8483
/** Event emitted when the tab completes its animation towards the center. */
85-
@Output()
86-
onCentered: EventEmitter<void> = new EventEmitter<void>(true);
84+
@Output() onCentered: EventEmitter<void> = new EventEmitter<void>(true);
8785

8886
/** The tab body content to display. */
8987
@Input('content') _content: TemplatePortal;

src/lib/tabs/tab-group.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,11 @@ export class MdTabGroup {
8484
return this.selectChange.map(event => event.index);
8585
}
8686

87-
private _onFocusChange: EventEmitter<MdTabChangeEvent> = new EventEmitter<MdTabChangeEvent>();
88-
8987
/** Event emitted when focus has changed within a tab group. */
90-
@Output() get focusChange(): Observable<MdTabChangeEvent> {
91-
return this._onFocusChange.asObservable();
92-
}
93-
94-
private _onSelectChange: EventEmitter<MdTabChangeEvent> =
95-
new EventEmitter<MdTabChangeEvent>(true);
88+
@Output() focusChange: EventEmitter<MdTabChangeEvent> = new EventEmitter<MdTabChangeEvent>();
9689

9790
/** Event emitted when the tab selection has changed. */
98-
@Output() get selectChange(): Observable<MdTabChangeEvent> {
99-
return this._onSelectChange.asObservable();
100-
}
91+
@Output() selectChange: EventEmitter<MdTabChangeEvent> = new EventEmitter<MdTabChangeEvent>(true);
10192

10293
private _groupId: number;
10394

@@ -121,7 +112,7 @@ export class MdTabGroup {
121112
// If there is a change in selected index, emit a change event. Should not trigger if
122113
// the selected index has not yet been initialized.
123114
if (this._selectedIndex != this._indexToSelect && this._selectedIndex != null) {
124-
this._onSelectChange.emit(this._createChangeEvent(this._indexToSelect));
115+
this.selectChange.emit(this._createChangeEvent(this._indexToSelect));
125116
}
126117

127118
// Setup the position for each tab and optionally setup an origin on the next selected tab.
@@ -147,7 +138,7 @@ export class MdTabGroup {
147138
}
148139

149140
_focusChanged(index: number) {
150-
this._onFocusChange.emit(this._createChangeEvent(index));
141+
this.focusChange.emit(this._createChangeEvent(index));
151142
}
152143

153144
private _createChangeEvent(index: number): MdTabChangeEvent {

0 commit comments

Comments
 (0)