To delta subscribe, you simply use the delta_subscribe command as follows:
const subId = await client.execute(
// The delta_subscribe command to execute
new Command('delta_subscribe')
.topic('delta-topic')
.filter('/thingIWant = "true"'),
// Message handler
message => { /* Delta messages arrive here */ }
);
// Once subscribed, it resolves with the subscription id.
console.log(subId);
The convenience method Client.deltaSubscribe() is available. If the delta_subscribe is not a valid command for the topic provided, a regular subscription will be created.
const subId = await client.deltaSubscribe(
message => { /* ... */ }, // Message handler
'delta-topic', // Topic
'/thingIWant = "true"' // Filter (optional)
);
// Once subscribed, it resolves with the subscription id.
console.log(subId);
As described in the AMPS User Guide, messages provided to a delta subscription will contain the fields used to generate the SOW key and any changed fields in the message. Your application is responsible for choosing how to handle the changed fields.