ProjectRevisionHandlerMixin
Properties
3
Properties
3Functions
4
Functions
4Revisions
Applies an array of revisions to a local project
| Parameter | Type | Description |
|---|---|---|
revisions | RevisionInfo | RevisionInfo[] |
Initializes revision feature on the project. Calling this API early is required for revisions to work.
| Parameter | Type | Description |
|---|---|---|
clientId | String | ID of the client. ID should be unique across all clients. Either server should provide it or UUID can be used. |
revisionId | String | 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) { }
})
| Parameter | Type | Description |
|---|---|---|
fn | function | |
handleReject | function |
CRUD
Events
1
Events
1This 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 }) => {
});| Parameter | Type | Description |
|---|---|---|
localRevisionId | String | ID of the local revision. Backend should send it in the broadcast channel |
conflictResolutionFor | String | ID of the revision with a conflict which was resolved by this revision |
clientId | String | ID of the client instance. Used to distinguish own revisions from the broadcast channel |
changes | Object | Object with changes constituting revision |
Event handlers
1
Event handlers
1This 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 }) {
}
});| Parameter | Type | Description |
|---|---|---|
localRevisionId | String | ID of the local revision. Backend should send it in the broadcast channel |
conflictResolutionFor | String | ID of the revision with a conflict which was resolved by this revision |
clientId | String | ID of the client instance. Used to distinguish own revisions from the broadcast channel |
changes | Object | Object with changes constituting revision |
Typedefs
1
Typedefs
1| Parameter | Type | Description |
|---|---|---|
revisionId | String | Number | Real ID of the revision. |
localRevisionId | String | Number | Local ID of the revision. |
conflictResolutionFor | String | Number | ID of the revision with a conflict which was resolved by this revision. |
clientId | String | Number | Id of the client to identify own changes. |
changes | Object | Changes to apply with the revision. |