question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose events as @Input() again (like in v4)

See original GitHub issue

In 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:closed
  • Created 3 years ago
  • Reactions:12
  • Comments:22 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
irustmcommented, Nov 21, 2020

@arshaw what do you think about it? I’m ready to change the API, and go back to the old way.

5reactions
blackholegalaxycommented, Jun 18, 2020

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"

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found