Expose events as @Input() again (like in v4)
See original GitHub issueIn v5, the component has only one input for all the options and I think this is a drawback for doing things the Angular way. I strongly prefer the v4 way of having everything as input or output, it’s clearer and conforms better to the Angular pattern, by the way…
[options] should be used for static configuration properties that presumably didn’t change during the lifespan of the component but events can change frequently and can be useful to have their input property expecially when using async pipe.
Here are two examples of (simplified) code taken from a project of mine that uses NGRX and where events can change from actions outside the calendar component (filtered by a search, added…).
Current v5 implementation:
template: <full-calendar *ngIf="(calendarOptions$ | async) as options" [options]="options"></full-calendar>
...
private readonly calendarOptions = {
plugins: [dayGridPlugin, timeGrigPlugin, interactionPlugin, listPlugin],
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
...
};
ngOnInit() {
this.calendarOptions$ = this.store.pipe(
select(EventsSelectors.selectEvents),
map(events => {
const newEvents = events
.map(event => ({
id: event.id,
title: event.title,
date: event.dueDate.toISOString(),
allDay: true,
editable: true,
}));
return { ...this.calendarOptions, events: newEvents };
})
);
}
Proposed implementation:
template: <full-calendar [options]"calendarOptions" [events]="events$ | async"></full-calendar>
...
public readonly calendarOptions = {
plugins: [dayGridPlugin, timeGrigPlugin, interactionPlugin, listPlugin],
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
...
};
ngOnInit() {
this.events$ = this.store.pipe(
select(EventsSelectors.selectEvents),
map(events => events.map(event => ({
id: event.id,
title: event.title,
date: event.dueDate.toISOString(),
allDay: true,
editable: true,
}))
)
);
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:22 (6 by maintainers)
Top Results From Across the Web
How to expose wrapped <input> in Vue? - Stack Overflow
I'm not sure there is a Vue way to achieve this, because, as far as I'm aware there is no way to bind...
Read more >Events | Unreal Engine Documentation
An event can only execute a single object. If you want to trigger multiple actions from one event, you will need to string...
Read more >Working with Angular 4 Forms: Nesting and Input Validation
Forms in Angular applications can aggregate the state of all inputs that are under that form and provide an overall state like the...
Read more >How to use Unity's Input System - YouTube
How to use the new input system in Unity! I go over installing the package, the different ways to use the input system,...
Read more >ASP.NET Core Blazor event handling - Microsoft Learn
An onclick event occurring in the child component is a common use case. To expose events across components, use an EventCallback.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@arshaw what do you think about it? I’m ready to change the API, and go back to the old way.
Agreed. Having to change options object when updating the events is kind of messy. As stated by @osmolo we load our events through NGRX effects and rely heavily on our store to get updated and new events. We expect to be able to pass the events like:
[events]="events$ | async"