-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add getEventSources and refetchEventSources methods to refetch specific event sources #3103
Conversation
This is very useful. I think you should add some tests though. |
Working on making some tests - something I don't have experience with yet. Currently, though, I'm getting errors even with the normal FullCalendar code (possibly fixed by #3101?) |
@arshaw Any comments/suggestions? |
what errors are you seeing? |
I'm getting the following errors when running the automated tests out of the master branch:
|
Can confirm that merging PR #3101 allows the tests to run without any errors. |
ccb082c
to
076d82d
Compare
Tests now passing successfully (both in master and this branch) after 2a600ea. |
Hi @caseyjhol , Thanks for this PR it is very helpful n my case, because i have many sources showing on single calendar, every time update,deleted i call |
When this will get merged? |
f9545e3
to
a5c8228
Compare
@caseyjhol et al, sorry for the long delay. Thanks for the work on this. I know I gave prior approval of the API, but after spending more time understanding it and looking at the resulting code, I'm hoping we can simplify. Sorry to chime in so late 😞 From what it looks like, Rather than provide utilities to filter which event sources get refetched, I'd rather put the filtering in the caller's control. So, they would get call So, I'm proposing a single change to the API: the addition of a |
That sounds good, and should be easy enough to implement. I do think we should also support passing through multiple sources as an array in one |
i definitely want to add |
rangeStart = start; | ||
rangeEnd = end; | ||
_cache = sourceFilter ? cache : []; | ||
cache = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will clear all events from the cache, even in the event sources we want refetched. the result (i believe) will be that other event sources' events will be unintentionally cleared
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Event sources' events we want to keep (i.e. not refetch) are stored in _events
in the source object. _events
is built using _cache
, which is only used in the case that we're using a filter. This line would probably make more sense as
if (sourceFilter) {
_cache = cache;
}
i'd rather pass in only one event source to HOWEVER, i understand there might be performance issues with multiple re-render. #2938 will solve this, but might be a while before it's implemented. thus, i'm okay with providing a method to refetch multiple resources all at once. could we please call it |
It might not be a bad idea to pass through an |
I've got this working and ready to go (not pushed to GitHub yet), but it is dependent on getEventSources existing, of course. I made a comment in #2433 about the best way to proceed with that feature. |
a5c8228
to
f35323a
Compare
getEventSources added in #3214. |
looks great 👍 |
I want to add some tests for this, but this relies on getEventSources, obviously. Do you want me to do the tests using a mock getEventSources function (like the one below), and then update the tests later after FullCalendar officially supports getEventSources? Or do you just want me to hold off on the tests? function getEventSources() {
var eventSources = [];
var events = $calendar.fullCalendar('clientEvents');
for (var i = 0; i < events.length; i++) {
var source = events[i].source;
if (eventSources.indexOf(source) === -1) {
eventSources.push(source);
}
}
return eventSources;
} |
could you actually just merge your other branch with |
getEventSources has been merged |
Added tests for refetchEventSources. |
good to go. thank you |
Code complete and docs written but not yet released. Will update this thread when released. @caseyjhol i added some mods/tests to deal w/ race conditions a bit better |
and http://fullcalendar.io/docs/event_data/refetchEventSources/ thank you for all your hard work @caseyjhol ! |
close #254
close #1328
Example here: http://embed.plnkr.co/6s2LGElJC7Fyy004cmUC/.
This example also includes getEventSources for the purpose of retrieving the event sources. In the example, when refetchEventSources is called, an array of refetched eventSource IDs are displayed below the calendar.