v7.3.0
SupportExamplesFree Trial

StateTrackingManager

StateTrackingManager subclass that's aware of the Scheduler Pro data structure specifics, namely supports tracking of event segment changes.

There is normally no need to deal with this class manually since it's instantiated automatically by the project and can be reached like this:

project.stm

Tracking store changes

Tracks the state of every store registered via addStore. It is disabled by default so remember to call enable when your stores are registered and initial dataset is loaded. Use undo / redo method calls to restore state to a particular point in time

stm = new StateTrackingManager({
    autoRecord : true,
    listeners  : {
       'recordingstop' : () => {
           // your custom code to update undo/redo GUI controls
           updateUndoRedoControls();
       },
       'restoringstop' : ({ stm }) => {
           // your custom code to update undo/redo GUI controls
           updateUndoRedoControls();
       }
   },
   getTransactionTitle : (transaction) => {
       // your custom code to analyze the transaction and return custom transaction title
       const lastAction = transaction.queue[transaction.queue.length - 1];

if (lastAction instanceof AddAction) { let title = 'Add new record'; }

return title; } });

stm.addStore(userStore); stm.addStore(companyStore); stm.addStore(otherStore);

stm.enable();

Resetting the queue on data loading

When loading data from the server it makes perfect sense to reset the queue.

If project (CrudManager protocol) is used for data loading it can be done like this:

project.on({
    load() {
        project.stm.resetQueue();
    }
});

and in case individual stores are used:

ajaxStore.on({
    load() {
        ajaxStore.stm.resetQueue();
    }
});

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isStateTrackingManager : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of StateTrackingManager class, or subclass thereof.
  • A class property getter for the default values of internal properties for this class.

Functions

Functions are methods available for calling on the class
  • This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    StateTrackingManager

    Registers this class type with its Factory

  • Internal function used to hook destroy() calls when using thisObj

  • Internal function used restore hooked destroy() calls when using thisObj

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    Internal function used to run a callback function after an event is triggered

  • Removes all listeners registered to this object by the application.

  • Clears committed revisions, we only need to use last one.

  • This method creates special conflict resolution revision which contains only conflict resolution actions. It is linked to the revision with a conflict via conflictResolutionFor property. Such revision cannot be rolled back locally because it will introduce the same conflict again.

  • This method creates special data revision which has no input state, only a data correction for a case when applying remote revisions lead to new changes. This revision will be sent, it should be persisted on the backend, and any client applying it should not see any changes after.

  • Disables manager

  • Enables manager

  • Used to distinguish user input from values calculated by the project. If any actions in the revision are marked as user input then checkout logic will only use user input. If nothing is marked, then revision is not treated specially.

  • Merges all update actions into one per model, keeping the oldest and the newest values.

  • Rejects currently recorded transaction.

  • Resets undo/redo queue.

  • Resets redo queue.

  • Resets undo queue.

  • Stops undo/redo recording transaction after autoRecordTransactionStopTimeout delay.

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

Event handlers

Event handlers are callbacks called as a result of certain actions in this class

Source path

SchedulerPro/data/stm/StateTrackingManager.js

Contents