Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Cleaned up the API and docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2ciek committed Aug 13, 2018
1 parent b6800cd commit f1934fa
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/autosave.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export default class Autosave extends Plugin {

const config = editor.config.get( 'autosave' ) || {};

// A minimum amount of time that needs to pass after the last action.
// After that time the provided save callbacks are being called.
const waitingTime = config.waitingTime || 2000;

/**
* The adapter is an object with a `save()` method. That method will be called whenever
* the data changes. It might be called some time after the change,
Expand All @@ -88,26 +92,18 @@ export default class Autosave extends Plugin {
this.set( 'state', 'synchronized' );

/**
* A minimum amount of time that needs to pass after the last action.
* After that time the provided save callbacks are being called.
*
* @protected
* @type {Number}
*/
this._waitingTime = config.waitingTime || 2000;

/**
* Throttled save method.
* Debounced save method. The `save` method is called the specified `waitingTime` after the `debouncedSave` is called,
* unless new action happens in the meantime.
*
* @protected
* @private
* @type {Function}
*/
this._debouncedSave = debounce( this._save.bind( this ), this._waitingTime );
this._debouncedSave = debounce( this._save.bind( this ), waitingTime );

/**
* Last document version.
*
* @protected
* @private
* @type {Number}
*/
this._lastDocumentVersion = editor.model.document.version;
Expand Down

0 comments on commit f1934fa

Please sign in to comment.