This new feature allows creating a sensor as follows
const processMonitor = Sensor.of<Processes>.from({
lens: '/:pid/status',
sensor: async function* ({ pid }) {
// yield the updated state of the process on changes
}
})
An agent created with the processMonitor sensor will create a new instance of the sensor and subscribe to it whenever a new process is created, and unsubscribe/destroy the sensor whenever the process is removed.
This adds a capability to Mahler Agents to create/destroy sensors whenever a property the sensor is referencing via a lens is created/removed.
For example, let's think of an agent to create and track the state of multiple proceses
This new feature allows creating a sensor as follows
An agent created with the
processMonitor
sensor will create a new instance of the sensor and subscribe to it whenever a new process is created, and unsubscribe/destroy the sensor whenever the process is removed.See here for an example within the tests
This PR also adds observable support to sensors and provides additional tools to work with observables
Change-type: minor