UNPKG

1.99 kBTypeScriptView Raw
1import { DocumentRegistry } from '@jupyterlab/docregistry';
2import { IDisposable } from '@lumino/disposable';
3/**
4 * A class that manages the auto saving of a document.
5 *
6 * #### Notes
7 * Implements https://github.com/ipython/ipython/wiki/IPEP-15:-Autosaving-the-IPython-Notebook.
8 */
9export declare class SaveHandler implements IDisposable {
10 /**
11 * Construct a new save handler.
12 */
13 constructor(options: SaveHandler.IOptions);
14 /**
15 * The save interval used by the timer (in seconds).
16 */
17 get saveInterval(): number;
18 set saveInterval(value: number);
19 /**
20 * Get whether the handler is active.
21 */
22 get isActive(): boolean;
23 /**
24 * Get whether the save handler is disposed.
25 */
26 get isDisposed(): boolean;
27 /**
28 * Dispose of the resources used by the save handler.
29 */
30 dispose(): void;
31 /**
32 * Start the autosaver.
33 */
34 start(): void;
35 /**
36 * Stop the autosaver.
37 */
38 stop(): void;
39 /**
40 * Set the timer.
41 */
42 private _setTimer;
43 /**
44 * Handle an autosave timeout.
45 */
46 private _save;
47 private _autosaveTimer;
48 private _minInterval;
49 private _interval;
50 private _context;
51 private _isConnectedCallback;
52 private _isActive;
53 private _inDialog;
54 private _isDisposed;
55 private _multiplier;
56}
57/**
58 * A namespace for `SaveHandler` statics.
59 */
60export declare namespace SaveHandler {
61 /**
62 * The options used to create a save handler.
63 */
64 interface IOptions {
65 /**
66 * The context associated with the file.
67 */
68 context: DocumentRegistry.Context;
69 /**
70 * Autosaving should be paused while this callback function returns `false`.
71 * By default, it always returns `true`.
72 */
73 isConnectedCallback?: () => boolean;
74 /**
75 * The minimum save interval in seconds (default is two minutes).
76 */
77 saveInterval?: number;
78 }
79}