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.

How do I correctly use a function as an event source?

See original GitHub issue

I’m not sure if this is a bug, or an intended functionality but whenever I access my method that I have indicated in the [events] property of <full-calendar></full-calendar>, calling this returns null, therefore, I cannot use my services.

Screenshot from 2019-05-16 13-22-05

Screenshot from 2019-05-16 13-25-48

Am I doing something wrong?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Nedddcommented, Jun 27, 2019

@dreadnautxbuddha This works. I personally like the first example

export class YourComponent implements OnInit {
  eventSources: Array<any> = [];

  constructor(){}

  ngOnInit() {
    this.eventSources = [ this.fetchEvents( this ) ]
  }

  fetchEvents( _this ) {
      return ( fetchInfo, successCallback, failureCallback ) => {
        _this.someAsyncCallToServer( fetchInfo ).then( ( events ) => {
          successCallback( event );
        } ).catch( ( error ) => {
          failureCallback( error );
        } );
      };
  }
}

OR

export class YourComponent implements OnInit {
  eventSources: Array<any> = [];

  constructor(){}

  ngOnInit() {
    this.eventSources = [ this.fetchEvents.bind(this) ]
  }

  fetchEvents( fetchInfo, successCallback, failureCallback) {
        this.someAsyncCallToServer( fetchInfo ).then( ( events ) => {
          successCallback( event );
        } ).catch( ( error ) => {
          failureCallback( error );
        } );
  }
}

Then: <full-calendar #calendar [plugins]="plugins" [eventSources]="eventSources" ></full-calendar>

Pieced together from: https://fullcalendar.io/docs/events-function

0reactions
ngardnercommented, Jul 8, 2019

Thank you @Neddd exactly what I needed as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lambda event source mappings - AWS Documentation
Configure a Lambda event source mapping to invoke your function from queue and stream event sources, such as Amazon SQS, Kinesis, and DynamoDB....
Read more >
Introduction to events - Learn web development | MDN
Events are actions or occurrences that happen in the system you are programming, which the system tells you about so your code can...
Read more >
How to know the JavaScript event source on function scope?
In that example, I'm trying to get source == 'timer' or 'onclick' , or any other information to determine which is the event...
Read more >
Introduction to browser events - The Modern JavaScript Tutorial
If the handler is assigned using an HTML-attribute then the browser reads it, creates a new function from the attribute content and writes...
Read more >
Event collector doesn't forward events - Windows Server
Describes an issue that occurs when you use source-initiated ... event forwarding may not function correctly in the default configuration.
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