Unexpected behaviour compared to akita store/query #441
-
I have been battling a timing issue with an Elf store. I reverted to my old akita favourites and the behaviour does not manifest. Could be a newbie Elf issue, but this is the code. Seems pretty straightforward to me...the property setters manifest from component This is the set up. Akita is streaming as expected private readonly elfStore = createStore({ name: 'CalendarComponentStateStore' }, withProps<CalendarComponentState>({}));
private readonly akitaStore = new Store<CalendarComponentState>({});
private readonly akitaQuery = new Query<CalendarComponentState>(this.akitaStore);
private calendarEvents$ = this.elfStore.pipe(select((s) => s.calendarEvents));
// calendarMonth$ = this.elfStore.pipe(select((s) => s.calendarMonth));
calendarMonth$ = this.akitaQuery.select(q => q.calendarMonth);
constructor(private navigatorStateService: CalendarNavigatorStateService) {
this.calendarEvents$.pipe(untilDestroyed(this)).subscribe(this.buildCalendar);
combineLatest([this.calendarEvents$, this.navigatorStateService.activeDate$]).pipe(untilDestroyed(this)).subscribe(this.buildCalendar);
}
set eventModels(eventModels: EventModel[]) {
this.elfStore.update(setProps({calendarEvents: new CalendarEventsList(eventModels) }));
} This is the store update code from this.elfStore.update(setProps({ calendarMonth }));
this.akitaStore.update({ calendarMonth }) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Please create a minimal reproduction in stackblitz of Elf example. |
Beta Was this translation helpful? Give feedback.
-
hacked-worked: ngOnInit() {
this.componentStateService.calendarMonth$.pipe(untilDestroyed(this)).subscribe((cm) => {
// bizarre issue where component no longer cycles once cm is undefined, hence no async pipe
if(cm) this.calendarMonth = cm;
});
} |
Beta Was this translation helpful? Give feedback.
hacked-worked: