Function monitor

  • State monitoring.

    Parameters

    • options: MonitorOptions

      Parameters options to be passed down to ip.

    • globalOptions: GlobalOptions = {}

      Global parameters options that affects the command execution.

    Returns Promise<MonitorCommand<MonitorOptions>>

    Throws

    ParametersError - Throws when passed parameters are invalid.

    Throws

    CommandError - Throws when the executed command fails.

    Example

    Import module

    import { monitor } from 'iproute';
    

    Monitor all objects state changes

    monitor({
    object: MonitorObjects.All
    });

    After starting the monitor, you can start watching for changes

    let command: MonitorCommand<MonitorOptions>;

    monitor({
    object: MonitorObjects.All
    })
    .then((_command) => {
    command = _command;

    command.on(MonitorObjects.All, (data: MonitorEmittedData) => {
    // Do something with `data`.
    });

    command.on('error', (error) => {
    // Do something with `data`.
    });
    });

    setTimeout(() => {
    command.close();
    }, 5000);

Generated using TypeDoc