summaryrefslogtreecommitdiff
path: root/std/signal
diff options
context:
space:
mode:
authorAndrew Mitchell <32021055+mitch292@users.noreply.github.com>2020-09-25 19:15:18 -0400
committerGitHub <noreply@github.com>2020-09-26 09:15:18 +1000
commit98c9798cb757045b3f46573c5baa80e2cfe672aa (patch)
treea4edc02542d201de5e540bb70e6f272090f1814e /std/signal
parent0ffaaba1648bab0cf8da04bbb9a2e1fac2ac60aa (diff)
docs(std): add async and signal readme (#7683)
Resolves #7608
Diffstat (limited to 'std/signal')
-rw-r--r--std/signal/README.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/std/signal/README.md b/std/signal/README.md
new file mode 100644
index 000000000..f58c742b9
--- /dev/null
+++ b/std/signal/README.md
@@ -0,0 +1,38 @@
+# signal
+
+signal is a module used to capture and monitor OS signals
+
+# usage
+
+The following functions are exposed in `mod.ts`
+
+## signal
+
+Generates an AsyncIterable which can be awaited on for one or more signals.
+`dispose()` can be called when you are finished waiting on the events.
+
+```typescript
+import { signal } from "https://deno.land.std/signal/mod.ts";
+const sig = signal(Deno.Signal.SIGUSR1, Deno.Signal.SIGINT);
+setTimeout(() => {}, 5000); // Prevents exiting immediately
+
+for await (const _ of sig) {
+ // ..
+}
+
+// At some other point in your code when finished listening:
+sig.dispose();
+```
+
+## onSignal
+
+Registers a callback function to be called on triggering of a signal event.
+
+```typescript
+import { onSignal } from "https://deno.land.std/signal/mod.ts";
+
+const handle = onSignal(Deno.Signal.SIGINT, () => {
+ // ...
+ handle.dispose(); // de-register from receiving further events
+});
+```