Last active
June 7, 2018 10:22
-
-
Save jtomaszewski/c18bbf53fc8255a45b34672ab0facbc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wrong (impure) | |
class DateTimePickerComponent { | |
timeZone: string = "Europe/Warsaw"; | |
constructor(private account: AccountService) { | |
if (this.account.currentUser) { | |
this.timeZone = this.account.currentUser.timeZone; | |
} | |
} | |
changeTimeZone(timeZone: string) { | |
this.timeZone = timeZone; | |
this.account.updateCurrentUser({ | |
timeZone | |
}); | |
} | |
} | |
// good (pure) | |
class DateTimePickerComponent { | |
@Input() timeZone: string = "Europe/Warsaw"; | |
@Output() timeZoneChange: EventEmitter<string> = new EventEmitter(); | |
changeTimeZone(timeZone: string) { | |
this.timeZoneChange.emit(timeZone); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment