Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demonstrating how to stop recording #20

Merged
merged 2 commits into from
Dec 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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