you can see the full code here: https://mattlewis92.github.io/angular-calendar/#/async-events
I'm trying to make a Calendar in Angular and I'm using the module angular-calendar, it's filling me correctly the async events in my calendar, the problem is when I try to fill it up with events that not needs to be requested from the API:
export interface CalendarEvent {
start: Date;
end?: Date;
title: string;
color: EventColor;
actions?: EventAction[];
allDay?: boolean;
cssClass?: string;
resizable?: {
beforeStart?: boolean;
afterEnd?: boolean;
};
draggable?: boolean;
}
interface Film {
id: number;
title: string;
release_date: string;
}
interface FilmEvent extends CalendarEvent {
film: Film;
}
events$: Observable;
this.events$ = this.http
.get('https://api.themoviedb.org/3/discover/movie', {search})
.map(res => res.json())
.map(({results}: {results: Film[]}) => {
return results.map((film: Film) => {
return {
title: film.title,
start: new Date(film.release_date),
color: colors.yellow,
film
};
});
});
as you can see the calendar is filled automatically by the changes on the Observable array events$ when requesting info from the API:
but the problem is that I haven't being able to manipulate the events$ array to simply add me a static event into the array, something like this:
title: "STATIC EVENT",
start: new Date(), ///TODAY
color: colors.yellow,
film
So far I have tried to use two http stream response like this, I saved some Statics events in JSON :
this.test3= this.http .get("adresssAPI1")
this.test4 = this.http .get("STATICSEVENTSINJSON")
and I have tried to merge them in just one stream to be processed as a single stream
this.test5 = Rx.Observable.combineLatest(this.test3 this.test4)
this.events$=
this.test5.map(({results}: {results: Film[]}) => {
return results.map((film: Film) => {
return {
title: film.title,
start: new Date(film.release_date),
color: colors.yellow,
film
};
});
});
I would appreciate any ideas to get this done, I'm a noob and I don't really understand very well how to manipulate an Observable Array