java-bridge
    Preparing search index...

    Function enableRedirect

    • Enable stdout/stderr redirection.

      Pass methods for the stdout and stderr output to be redirected to. These methods must accept an error as the first argument, although this will probably never be set and can be ignored. The second argument is the data that was redirected.

      Setting any method to null or undefined will disable the redirect for that method. This also allows you not set any handler which does not make any sense at all.

      import { stdout } from 'java-bridge';

      const guard = stdout.enableRedirect((_, data) => {
      console.log('Stdout:', data);
      }, (_, data) => {
      console.error('Stderr:', data);
      });
      const guard = stdout.enableRedirect((_, data) => {
      console.log('Stdout:', data);
      });
      const guard = stdout.enableRedirect(null, (_, data) => {
      console.error('Stderr:', data);
      });

      This enables you to print nothing to nowhere.

      // Why would you do this?
      const guard = stdout.enableRedirect(null, null);

      // Or
      const guard = stdout.enableRedirect();

      Parameters

      • Optionalstdout: null | StdoutCallback

        the callback to be called when stdout is received

      • Optionalstderr: null | StdoutCallback

        the callback to be called when stderr is received

      Returns StdoutRedirectGuard

      a StdoutRedirectGuard instance. Keep this instance in scope to not lose the redirect.

      • StdoutRedirectGuard
      • StdoutCallback