Skip to content

Commit

Permalink
Update docs. PrettyMonitor compatibility ftw
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Apr 4, 2014
1 parent eb2e62f commit 6410fd0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions docs/api.md
Expand Up @@ -1840,11 +1840,11 @@ tl;dr Load `when/monitor/console` and get awesome async stack traces, even if yo
```js
require('when/monitor/console');
var Promise = require('when').Promise;
var when = require('when');

Promise.resolve().then(function f1() {
Promise.resolve().then(function f2() {
Promise.resolve().then(function f3() {
when.resolve().then(function f1() {
when.resolve().then(function f2() {
when.resolve().then(function f3() {
doh();
});
});
Expand All @@ -1864,7 +1864,7 @@ from execution context:
It monitors promise state transitions and then takes action, such as logging to the console, when certain criteria are met, such as when a promise has been rejected but has no `onRejected` handlers attached to it, and thus the rejection would have been silent.
Since promises are asynchronous and their execution may span multiple disjoint stacks, it can also attempt to stitch together a more complete stack trace. This synthesized trace includes the point at which a promise chain was created, through all promises in the chain to the point where the rejection "escaped" the end of the chain without being handled.
Since promises are asynchronous and their execution may span multiple disjoint stacks, it will also attempt to stitch together a more complete stack trace. This synthesized trace includes the point at which a promise chain was created, through other promises in the chain to the point where the rejection "escaped" the end of the chain without being handled.
## Using it
Expand Down Expand Up @@ -1900,12 +1900,10 @@ require('when/monitor/console');
browserify -s PromiseMonitor when/monitor/console.js -o PromiseMonitor.js
```
### PrettyMonitor for when 2.x and Node
### PrettyMonitor for when.js and Node
[PrettyMonitor](https://github.com/AriaMinaei/pretty-monitor) by [@AriaMinaei](https://github.com/AriaMinaei) is an alternative promise monitor on Node. It's built using when.js's own monitoring apis and modules, and provides a very nice visual display of unhandled rejections in Node.
Currently, PrettyMonitor is compatible with when 2.x, and will be updated to work with 3.x soon!
## Roll your own!
The monitor modules are building blocks. The [when/monitor/console](../monitor/console.js) module is one particular, and fairly simple, monitor built using the monitoring APIs and tools (PrettyMonitor is another, prettier one!). Using when/monitor/console as an example, you can build your own promise monitoring tools that look for specific types of errors, or patterns and log or display them in whatever way you need.
Expand Down

0 comments on commit 6410fd0

Please sign in to comment.