import { IPC } from'@empathize/framework';IPC.read().then((records) => {records.forEach((record) => {if (record.data =='test-data')record.pop(); // Otherwise this record will remain in IPC.read() output });});
record.get()
Get object of record values
import { IPC } from'@empathize/framework';IPC.read().then((records) => {records.forEach((record) => {if (record.data =='test-data') {// record.pop() method returns this record after its deletion// and we can call its .get() method after thatconstrecordData=record.pop().get();// It will output { id: '...', time: '...', data: '...' }console.log(recordData); } });});
import { IPC } from'@empathize/framework';// It can be string, ..IPC.write('test-record');// ..object or something elseIPC.write({ example_field:'example_value'});
IPC.remove(record)
Remove record
import { IPC } from'@empathize/framework';IPC.write('test-record').then((record) => {// Remove this record after 3 secondssetTimeout(() => {// Can be IPCRecord object or record idIPC.remove(record); },3000);});
IPC.purge()
Remove all records
import { IPC, promisify } from'@empathize/framework';promisify(async () => {// Add 10 recordsfor (let i =0; i <10; ++i)awaitIPC.write('test');// Records amount: 10console.log(`Records amount: ${(awaitIPC.read()).length}`);// Remove all recordsawaitIPC.purge();// Records amount: 0console.log(`Records amount: ${(awaitIPC.read()).length}`);});