Skip to content

Commit

Permalink
demonstrating how to stop recording (rrweb-io#20)
Browse files Browse the repository at this point in the history
* demonstrating how to stop recording

* made record stop example seperate
  • Loading branch information
ChuckJonas authored and Yuyz0112 committed Dec 31, 2018
1 parent 0f22749 commit d25a96e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ rrweb does **not** support IE11 and below, because it uses the `MutationObserver
### Record

If you only include record code with `<script>`, then you can use the global variable `rrwebRecord` which is the same as `rrweb.record`.
The following sample codes will use the variable `rrweb` which is the default exporter of this library.
The following sample code will use the variable `rrweb` which is the default exporter of this library.

```js
rrweb.record({
Expand All @@ -58,7 +58,19 @@ rrweb.record({
});
```

During recording, the recorder will emit when there is some event incurred, all you need to do is to store the emitted events in any way you like.
During recording, the recorder will emit when there is some event incurred, all you need to do is to store the emitted events in any way you like.

The `record` method returns a function which can be called to stop events from firing:

```js
let stopFn = rrweb.record({
emit(event) {
if(events.length > 100){ //stop after 100 events
stopFn();
}
}
});
```

A more real-world usage may looks like this:

Expand Down

0 comments on commit d25a96e

Please sign in to comment.