Skip to content
This repository has been archived by the owner on Feb 2, 2019. It is now read-only.

Commit

Permalink
fix: use synchronous event emitters to workaround dehydrated detectors
Browse files Browse the repository at this point in the history
 - see angular/angular#6786 (comment)
 - todo: revisit if the #6786 issue finds resolution
 - closes #55
  • Loading branch information
justindujardin committed Feb 24, 2016
1 parent 89d4b37 commit 85cab59
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 18 deletions.
8 changes: 4 additions & 4 deletions ng2-material/components/backdrop/backdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@ export class MdBackdrop {
* Emits when the backdrop begins to hide.
*/
@Output()
onHiding: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>();
onHiding: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>(false);

/**
* Emits when the backdrop has finished being hidden.
*/
@Output()
onHidden: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>();
onHidden: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>(false);


/**
* Emits when the backdrop begins to be shown.
*/
@Output()
onShowing: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>();
onShowing: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>(false);

/**
* Emits when the backdrop has finished being shown.
*/
@Output()
onShown: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>();
onShown: EventEmitter<MdBackdrop> = new EventEmitter<MdBackdrop>(false);

constructor(public element: ElementRef) {
}
Expand Down
2 changes: 1 addition & 1 deletion ng2-material/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {parseTabIndexAttribute} from "../../core/util/util";
export class MdCheckbox {

@Output()
checkedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
checkedChange: EventEmitter<boolean> = new EventEmitter<boolean>(false);

/** Whether this checkbox is checked. */
@Input()
Expand Down
10 changes: 1 addition & 9 deletions ng2-material/components/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ export * from './dialog_container';
export * from './dialog_ref';
export * from './dialog_basic';

// TODO(jelbourn): body scrolling is disabled while dialog is open.
// TODO(jelbourn): Don't manually construct and configure a DOM element. See #1402
// TODO(jelbourn): Wrap focus from end of dialog back to the start. Blocked on #1251
// TODO(jelbourn): Focus the dialog element when it is opened.
// TODO(jelbourn): Pre-built `alert` and `confirm` dialogs.
Expand Down Expand Up @@ -110,13 +108,7 @@ export class MdDialog {
backdropRef.instance.hide().then(() => {
containerRef.dispose();
contentRef.dispose();
// TODO(jd): The change detection doesn't like it if you dispose() a ComponentRef while it has
// pending async things that will emit() one of it's outputs. Wait a second for the
// container objects to be disposed and clean up their Change detection references to
// the backdrop's hide/show events, then dispose of the backdrop.
TimerWrapper.setTimeout(()=> {
backdropRef.dispose();
}, 500);
backdropRef.dispose();
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion ng2-material/components/ink/ink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Ink} from "../../core/util/ink";
})
export class MdInk {

@Output() inked:EventEmitter<MdInk> = new EventEmitter<MdInk>();
@Output() inked:EventEmitter<MdInk> = new EventEmitter<MdInk>(false);

constructor(private _element: ElementRef) {
}
Expand Down
4 changes: 2 additions & 2 deletions ng2-material/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export class MdInput {
@Input()
placeholder: string;
@Output('valueChange')
mdChange: EventEmitter<any> = new EventEmitter();
mdChange: EventEmitter<any> = new EventEmitter(false);
@Output()
mdFocusChange: EventEmitter<any> = new EventEmitter();
mdFocusChange: EventEmitter<any> = new EventEmitter(false);

setHasFocus(hasFocus: boolean) {
ObservableWrapper.callEmit(this.mdFocusChange, hasFocus);
Expand Down
2 changes: 1 addition & 1 deletion ng2-material/components/radio/radio_button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _uniqueIdCounter: number = 0;
export class MdRadioGroup implements OnChanges {

@Output('valueChange')
change: EventEmitter<any> = new EventEmitter();
change: EventEmitter<any> = new EventEmitter(false);

/** The selected value for the radio group. The value comes from the options. */
@Input('value')
Expand Down

0 comments on commit 85cab59

Please sign in to comment.