Changes API: How to Subscribe to Operation Changes
The following methods allow you to subscribe to operation changes:
forOperation
Operation changes for one operation can be observed using the forOperationId()
method.
Syntax
store.changes().forOperationId(operationId);
Parameters | ||
---|---|---|
operationId | number | ID of an operation for which notifications will be processed. |
Return value | |
---|---|
IChangesObservable<OperationStatusChange> | Observable that allows you to add subscriptions to notifications for an operation with a given ID. |
Example
store.changes().forOperationId(operationId)
.on("data", change => {
const operationState = change.state;
// do something
});
forAllOperations
Operations changes for all Operations can be observed using the forAllOperations()
method.
Return Value | |
---|---|
IChangesObservable<OperationStatusChange> | Observable that allows to add subscriptions to notifications for all operations. |
Syntax
store.changes().forAllOperations();
Example
store.changes().forAllOperations()
.on("data", change => {
console.log("Operation #" + change.operationId);
});
OperationChange
Properties
Name | Type | Description |
---|---|---|
state | object | Operation state |
operationId | number | Operation ID |