How to trigger data load in the new Scheduler?

I’ve gone through many articles and API example. Please help me to figure this out. I’m using the new Scheduler component, the one that is Jet based. I have my own data layer, so I’d like to use that instead of a built in service.
I’ve extended the scheduler.services.Backend to stub events() with my own code.
I’m observing state. But I can’t figure out how to trigger scheduler into firing events() upon state.date or state.mode change.
Please help, thanks in advance!

Hello @dyankin,

I’ve extended the scheduler.services.Backend to stub events() with my own code. I’m observing state. But I can’t figure out how to trigger scheduler into firing events() upon state.date or state.mode change.

In general, it all depends on the way you are currently extending the existing Backend service (and whether you are extending it in the first place at all, or using your own “service” to fetch the data instead). If you follow Scheduler customization guide, you can apply the same customization principles to the existing services, meaning you can also override the existing Backend service, providing your own custom events() method and returning appropriate data.

If everything has been done correctly in regards to the Backend service override, the events() method will be triggered automatically by the component to fetch the data (which is why it is not entirely clear as to why you would want to manually trigger this method in the first place). Could you please clarify as to how the events() method is implemented in your case and why you would want to manually trigger it?

Please take a look at the following example: Code Snippet. Is this similar to what you are trying to achieve?

Some important notes regarding the customization shown above:

  1. The events() method must return a promise object that resolves with data.
  2. After extending the base Backend service, don’t forget to provide an override inside the Scheduler widget, so that you can replace the standard service with your own.

As you can see, provided that the steps above are followed correctly, we can even observe the state and trigger the method accordingly to fetch the data (in case you ever need to do so for any particular reason). But, in general, as long as you are not implementing some extra logic, you do not need to manually call the events() method (as it will get called automatically by the component as needed, as noted above).