Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Aug 22, 2020
1 parent 7008e13 commit 58d3aa8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -114,6 +114,27 @@ const initOptions = {

See the API below for all the methods and options that you have.

Below is a safe forwarding implemented in TypeScript, for events `connect`, `disconnect` and `query`.
It works the same for all other events.

```ts
import * as monitor from 'pg-monitor';

const forward = (event: monitor.LogEvent, args: IArguments) => (monitor as any)[event].apply(monitor, [...args]);

const options: IInitOptions = {
connect() {
forward('connect', arguments); // safe event forwarding into pg-monitor
},
disconnect() {
forward('disconnect', arguments);
},
query() {
forward('query', arguments);
}
};
```

# API

## attach(options, [events], [override])
Expand Down

0 comments on commit 58d3aa8

Please sign in to comment.