Skip to content

Commit b13fce3

Browse files
Docsp-17936 Watch For Changes Typescript (#228)
Co-authored-by: dariakp <[email protected]>
1 parent 1f22ce8 commit b13fce3

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

source/code-snippets/usage-examples/changeStream.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ async function run() {
3131
});
3232
// wait to close `changeStream` after the listener receives the event
3333
setTimeout(async () => {
34-
resolve(await changeStream.close());
34+
resolve(
35+
await changeStream.close(() => console.log("closed the change stream"))
36+
);
3537
}, 1000);
3638
}, 1000);
3739
});

source/usage-examples/changeStream.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,26 @@ callback process the event before exiting.
106106

107107
.. include:: /includes/connect-guide-note.rst
108108

109-
.. literalinclude:: /code-snippets/usage-examples/changeStream.js
110-
:language: javascript
109+
.. tabs::
110+
111+
.. tab:: JavaScript
112+
:tabid: javascript
113+
114+
.. literalinclude:: /code-snippets/usage-examples/changeStream.js
115+
:language: javascript
116+
:linenos:
117+
118+
.. tab:: TypeScript
119+
:tabid: typescript
120+
121+
.. literalinclude:: /code-snippets/usage-examples/changeStream.js
122+
:language: javascript
123+
:linenos:
124+
125+
.. note:: Identical Code Snippets
126+
127+
The JavaScript and TypeScript code snippets above are identical. There are no
128+
TypeScript specific features of the driver relevant to this use case.
111129

112130
If you run the example above, you should see output similar to the
113131
following:
@@ -124,6 +142,7 @@ following:
124142
ns: { db: 'sample_mflix', coll: 'movies' },
125143
documentKey: { _id: 5ec3... },
126144
}
145+
closed the change stream
127146

128147
.. note:: Receive Full Documents From Updates
129148

0 commit comments

Comments
 (0)