Navigation

Logging

The log method passes the LazyPromise along without changing its identity but adds logging of everything that happens to it: lazyPromise.log("your label"). While callbacks are running, log patches console.log so that the arguments are prefixed with dots indicating causality, so

box(42)
  .log("a")
  .map(() => {
    console.log("mapping");
  })
  .subscribe();

logs

[a] [1] [subscribe] undefined
· [a] [1] [resolve] 42
· · mapping

Dots reset whenever an async boundary is crossed. The numbers in the second pair of brackets are used for disambiguation when a label is reused. If you’re not using dependency injection, ignore the undefined you see next to [subscribe].