You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -240,6 +240,7 @@ The record service is a plain object defining some metadata and hooks:
240
240
-`didStartRecording`: Function that is called after the recording starts. [Read more below.](#hooks)
241
241
-`didStopRecording`: Function that is called after the recording stops. [Read more below.](#hooks)
242
242
-`willEnable`: Function that is called when the user enables the service. [Read more below.](#hooks)
243
+
-`cleanUp`: Function that is called if Kap exited unexpectedly last time it was run (for example, if it crashed), without the `didStopRecording` hook being called. This hook will only receive the `persistedState` object from the `state` passed to the rest of the hooks. Use this to clean up any effects introduced when the recording started and don't automatically clear out once Kap stops. For example, if your plugin killed a running app with intent to restart it after the recording was over, you can use `cleanUp` to ensure the app is properly restarted even in the event that Kap crashed, so the `didStopRecording` wasn't called.
243
244
244
245
The `config`, `configDescription` and hook properties are optional.
245
246
@@ -286,7 +287,8 @@ You can use this to check if you have enough permissions for the service to work
286
287
287
288
The hook functions receive a `context` argument with some metadata and utility methods.
288
289
289
-
-`.state`: A plain empty object that will be shared and passed to all hooks in the same recording process. It can be useful to persist data between the different hooks.
290
+
-`.state`: An object that will be shared and passed to all hooks in the same recording process. It can be useful to persist data between the different hooks.
291
+
-`state.persistedState`: An object under `state` which should only contain serializable fields. It will be passed to the `cleanUp` hook if Kap didn't shut down correctly last time it was run. Use this to store fields necessary to clean up remaining effects.
290
292
-`.apertureOptions`: An object with the options passed to [Aperture](https://github.com/wulkano/aperture-node). The API is described [here](https://github.com/wulkano/aperture-node#options).
291
293
-`.config`: Get and set config for your plugin. It’s an instance of [`electron-store`](https://github.com/sindresorhus/electron-store#instance).
292
294
-`.request()`: Do a network request, like uploading. It’s a wrapper around [`got`](https://github.com/sindresorhus/got).
0 commit comments