Created
January 9, 2020 12:51
-
-
Save Verthon/4673db59f4c2b23409bf94302e6d3638 to your computer and use it in GitHub Desktop.
This file contains 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
ngOnInit() { | |
console.log('ngOnInit() invokes with default group', this.defaultGroup); | |
const filter$: Observable<string> = this.filterControl.valueChanges.pipe( | |
startWith(''), | |
debounceTime(100), | |
distinctUntilChanged(), | |
share() | |
); | |
this.dayOverViewByGroup$ = this.attendanceService.getDayOverViewByGroupIdObservable(moment().format("YYYY-MM-DD"), 3).pipe( | |
// If the Observable from your service can emit 'null' and you do | |
// map(days => days.map(..)) you will get an error | |
// so you might have to handle this case here | |
// 1. Option: filter out 'null' and 'undefined' values before your 'map' and don't emit anything | |
//filter(Boolean) | |
// 2. Option: handle 'null' and 'undefined' in your map function | |
map(days => { | |
if (days && days === undefined) { | |
console.log('days inside of', days) | |
days.map(day => { | |
console.log('day in map', day); | |
return day; | |
}) | |
} else { | |
// do something else or don't do anything at all, i.e. remove the else case | |
return false; | |
} | |
}) | |
) ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment