Hello,
The application we are building is a planning application that uses Scheduler Pro. It has the concept of a planned and an actual view of the same events. For example: I can have a planned schedule for visits, but that does not mean that the visits happen at the planned date, so we record actual start date and end date for a visit once it has happened.
Our data model is simple, we have the same model with planned and actual dates on it that are initially equal, so they are never undefined. We map this model based on current view and feed it to the EventStore. In other words, depending on view mode, we map the planned or actual start dates to the startDate and endDate of the ModelConfig that is fed to the EventStore.data property. This is our mapping, not to be mistaken with the fields() static getter that the EventStore uses to do its own mapping.
The problem we see with this approach is that it is inefficient. We have to reload the same data just to change two fields, doing unnecessary malloc, project model has to rebuild, etc. As a side effect, we also can get React state to become out of sync with Scheduler if for example we store Scheduler data types in state, like selected events. If some events are selected and we feed new data to the EventStore, Scheduler keeps the previously selected events if possible, probably matched by ID. But then any previous event models we might have stored in React state are from a previous data load and now out of sync with Scheduler, and who knows what can happen if we try to use them, to call EvenModel APIs for example.
So, my question is, is there any other way to implement this kind of planned vs actual view switch on the same loaded data that is more efficient?
We thought of iterating over all events that we can get with getById and update their start and end dates but that is also very inefficient because of malloc of EventModels just to change two fields. Scheduler doesn't actually preallocate these objects I assume. Otherwise I can't imagine it being as fast and efficient as it is.
Another way we thought it might work is if we changed the static EventModel.fields getter to "flip" the dataSource of the startDate and endDate, assuming there is a way to let Scheduler know of this change and having it react to it.
Ultimately what we would hope for is a way to have Scheduler do the least amount of work in this scenario, which to us seems to be just a matter of updating the dataSource of a couple of fields and reflect that change in the DOM.
I might be wrong on many assumptions made here, so please forgive me and please let me know where I'm wrong and if there is a better way to implement what I've just described.
Thank you!