Refactor Polling Mechanism: Implement Class-Based Poller with Start/Stop Control (#528)
* custom module updates to class based. * Finish poller logic. * Use composition for pollers * Rename poller * Handle recorder polling. * Fix quotes in bash command * Remove logs
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
|
||||
// @ts-expect-error: This import is a special directive that tells the compiler to use the GTop library
|
||||
import GTop from 'gi://GTop';
|
||||
|
||||
import { pollVariable } from 'customModules/PollVar';
|
||||
import { FunctionPoller } from 'lib/poller/FunctionPoller';
|
||||
|
||||
class Cpu {
|
||||
private updateFrequency = Variable(2000);
|
||||
@@ -15,7 +14,14 @@ class Cpu {
|
||||
GTop.glibtop_get_cpu(this.previousCpuData);
|
||||
|
||||
this.calculateUsage = this.calculateUsage.bind(this);
|
||||
pollVariable(this.cpu, [], this.updateFrequency.bind('value'), this.calculateUsage);
|
||||
const cpuPoller = new FunctionPoller<number, []>(
|
||||
this.cpu,
|
||||
[],
|
||||
this.updateFrequency.bind('value'),
|
||||
this.calculateUsage,
|
||||
);
|
||||
|
||||
cpuPoller.start();
|
||||
}
|
||||
|
||||
public calculateUsage(): number {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const GLib = imports.gi.GLib;
|
||||
|
||||
import { pollVariable } from 'customModules/PollVar';
|
||||
import { FunctionPoller } from 'lib/poller/FunctionPoller';
|
||||
import { GenericResourceData } from 'lib/types/customModules/generic';
|
||||
|
||||
class Ram {
|
||||
@@ -13,7 +13,14 @@ class Ram {
|
||||
|
||||
constructor() {
|
||||
this.calculateUsage = this.calculateUsage.bind(this);
|
||||
pollVariable(this.ram, [], this.updateFrequency.bind('value'), this.calculateUsage);
|
||||
const ramPoller = new FunctionPoller<GenericResourceData, []>(
|
||||
this.ram,
|
||||
[],
|
||||
this.updateFrequency.bind('value'),
|
||||
this.calculateUsage,
|
||||
);
|
||||
|
||||
ramPoller.start();
|
||||
}
|
||||
|
||||
public calculateUsage(): GenericResourceData {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// @ts-expect-error: This import is a special directive that tells the compiler to use the GTop library
|
||||
import GTop from 'gi://GTop';
|
||||
|
||||
import { pollVariable } from 'customModules/PollVar';
|
||||
import { FunctionPoller } from 'lib/poller/FunctionPoller';
|
||||
import { GenericResourceData } from 'lib/types/customModules/generic';
|
||||
|
||||
class Storage {
|
||||
@@ -14,7 +14,14 @@ class Storage {
|
||||
|
||||
constructor() {
|
||||
this.calculateUsage = this.calculateUsage.bind(this);
|
||||
pollVariable(this.storage, [], this.updateFrequency.bind('value'), this.calculateUsage);
|
||||
const storagePoller = new FunctionPoller<GenericResourceData, []>(
|
||||
this.storage,
|
||||
[],
|
||||
this.updateFrequency.bind('value'),
|
||||
this.calculateUsage,
|
||||
);
|
||||
|
||||
storagePoller.start();
|
||||
}
|
||||
|
||||
public calculateUsage(): GenericResourceData {
|
||||
|
||||
Reference in New Issue
Block a user