Closed rreganjr closed 2 years ago
I removed subscribe from ngOnInit and moved all the code to figure out the visible agenda items plus pre/post item into a fuction getVisibleAgendaItemsPlus and in the constructor I build out the desired observable by using map() of the getVisibleAgendaItemsPlus() followed by map() of injectDropZones() following the debounceTime(). Instead of subscribing and passing the visible items through the _visibleAgendaItemsSubject and subscribing to an observable of that, I set a readlonly visibleAgendaItems$ to the pipe() and subscribe to that in the html template.
follow up commit on this in master.
In channel component the visibleAgendaItems$ observable needs to be defined in ngOnInit() so the inputs resourceName and channelName are defined and the correct observable for this channel is returned by scheduler service getAgendaItemsByResourceChannel$()
I was inspired by Why You Should Not Put Any Logic in the RxJS Subscribe Callback in Angular to clean up the way the channel determines the visible items and drop-zones.
A lot of work happens after the subscribe to agenda items and timescale changes and I create a subject that I next() the visible items and I observe that in the html template.
The goal is to move all the work out of the subscribe into a pipe on the combineLatest([agendaItems, timescale]) that returns the visible agenda items and remove the extra subject. the html template will subscribe to the end of the pipe