Realtime
With this namespace, you can quickly provide methods to manipulate live updates.
The namespace Realtime provides to developers, methods to easily subscribe, unsubscribe, save subscriptions and get subscriptions from documents.
//accessing to Realtime methods
SW.Realtime.{methodName}
getCurrentSubscriptions
Description
This method can be used to get the all current subscriptions.
Method(s)
1 declare function getCurrentSubscriptions(): {[key: string]: DocumentSubscription[]};
Basic Usage
SW.Realtime.getCurrentSubscriptions();
getDocumentComponentSubscription
Description
This method can be used to get a document subscription and the component.
Method(s)
1 declare function getDocumentComponentSubscription(documentType: string, documentId: string, component: any)): DocumentComponentSubscription;
Parameter | Type | Required | Defaults | Description |
---|---|---|---|---|
documentType | string | true | Document type | |
documentId | string | true | Document id | |
component | any | true | Component where was subscribed |
Basic Usage
SW.Realtime.getDocumentComponentSubscription('job', 'jobId', e.component);
saveDocumentComponentSubscription
Description
This method can be used to save a document subscription and the component.
Method(s)
1 declare function saveDocumentComponentSubscription(documentType: string, documentId: string, component: any, documentSubscription: DocumentSubscription)): void;
Parameter | Type | Required | Defaults | Description |
---|---|---|---|---|
documentType | string | true | Document type | |
documentId | string | true | Document id | |
component | any | true | Component where was subscribed | |
documentSubscription | DocumentSubscription | true | The document subscription |
Basic Usage
SW.Realtime.saveDocumentComponentSubscription('job', 'jobId', e.component,
{
documentInfo: {
DocumentId: 'jobId',
DocumentTypeName: 'job'
},
eventsCallbacks: {
onDocumentUpdated: () => {}
},
component: e.component
}
);
subscribeDocuments
Description
This method can be used to subscribe documents.
Method(s)
1 declare function subscribeDocuments(documents: DocumentInfoModel[], eventsCallbacks: EventsCallbacks, component: any): Promise<DocumentSubscription[]>;
Parameter | Type | Required | Defaults | Description |
---|---|---|---|---|
documents | DocumentInfoModel | true | Documents to subscribe | |
eventsCallbacks | EventsCallbacks | true | Callbacks after some events | |
component | any | true | Component where is subscribed |
Basic Usage
SW.Realtime.subscribeDocuments(
[{
DocumentId: 'jobId',
DocumentTypeName: 'job'
}],
{
onDocumentUpdated: () => {}
},
e.component
);
unsubscribeDocuments
Description
This method can be used to unsubscribe Documents.
Method(s)
1 declare function unsubscribeDocuments(documentSubscriptions: DocumentSubscription[]): Promise<any>;
Parameter | Type | Required | Defaults | Description |
---|---|---|---|---|
documentSubscriptions | DocumentSubscription[] | true | Documents subscriptions |
Basic Usage
SW.Realtime.unsubscribeDocuments(
[{
documentInfo: {
DocumentId: 'jobId',
DocumentTypeName: 'job'
},
eventsCallbacks: {
onDocumentUpdated: () => {}
},
component: e.component
}]
);