ProjectRevisionHandlerMixin

Properties

3
isProjectRevisionHandlerMixin: Boolean= truereadonly
Identifies an object as an instance of ProjectRevisionHandlerMixin class, or subclass thereof.
isProjectRevisionHandlerMixin: Boolean= truereadonlystatic
Identifies an object as an instance of ProjectRevisionHandlerMixin class, or subclass thereof.
isProjectChangeHandlerMixinProjectChangeHandlerMixin

Functions

4

Revisions

Applies an array of revisions to a local project

ParameterTypeDescription
revisionsRevisionInfo | RevisionInfo[]
Returns: Promise

Initializes revision feature on the project. Calling this API early is required for revisions to work.

ParameterTypeDescription
clientIdString

ID of the client. ID should be unique across all clients. Either server should provide it or UUID can be used.

revisionIdString

ID of the initial revision.

Use this method to organize project changes into transactions. Every queue call will create a sequential promise which cannot be interrupted by other queued functions. You can use async functions and await for any promises (including commitAsync) with one exception - you cannot await other queued calls and any other function/promise which awaits queued function. Otherwise, an unresolvable chain of promises will be created.

NOTE: Functions which call this method internally are marked with on-queue tag.

Examples:

// Invalid queue call which hangs promise chain
project.queue(async () => {
    const event = project.getEventStore().getById(1);
    await project.queue(() => {
        event.duration = 2;
        return project.commitAsync();
    })
})

// Valid queue call
project.queue(() => {
    const event = project.getEventStore().getById(1);

    // Consequent queue call will be chained after the current function in the next microtask.
    project.queue(() => {
        event.duration = 2;
        return project.commitAsync();
    })

    // Event duration is not yet changed - this condition is true
    if (event.duration !== 2) { }
})
ParameterTypeDescription
fnfunction
handleRejectfunction

CRUD

applyProjectChangesProjectChangeHandlerMixin

Events

1

This event triggers when a new revision is added to the project. It is used to notify the backend about the new revision.

// Adding a listener using the "on" method
projectRevisionHandlerMixin.on('revisionNotification', ({ localRevisionId, conflictResolutionFor, clientId, changes }) => {

});
ParameterTypeDescription
localRevisionIdString

ID of the local revision. Backend should send it in the broadcast channel

conflictResolutionForString

ID of the revision with a conflict which was resolved by this revision

clientIdString

ID of the client instance. Used to distinguish own revisions from the broadcast channel

changesObject

Object with changes constituting revision

Event handlers

1

This event triggers when a new revision is added to the project. It is used to notify the backend about the new revision.

new ProjectRevisionHandlerMixin({
    onRevisionNotification({ localRevisionId, conflictResolutionFor, clientId, changes }) {

    }
});
ParameterTypeDescription
localRevisionIdString

ID of the local revision. Backend should send it in the broadcast channel

conflictResolutionForString

ID of the revision with a conflict which was resolved by this revision

clientIdString

ID of the client instance. Used to distinguish own revisions from the broadcast channel

changesObject

Object with changes constituting revision

Typedefs

1
ParameterTypeDescription
revisionIdString | Number

Real ID of the revision.

localRevisionIdString | Number

Local ID of the revision.

conflictResolutionForString | Number

ID of the revision with a conflict which was resolved by this revision.

clientIdString | Number

Id of the client to identify own changes.

changesObject

Changes to apply with the revision.