lib/documentmanager.js
function DocumentManager(generator, config, logger, options) {
        EventEmitter.call(this);
        
        this._generator = generator;
        this._config = config;
        this._logger = logger;
        
        options = options || {};
        this._getDocumentInfoFlags = options.getDocumentInfoFlags;
        this._clearCacheOnChange = options.clearCacheOnChange;

        this._documents = {};
        this._documentDeferreds = {};
        this._documentChanges = {};

        this._openDocumentIds = {};
        this._newOpenDocumentIds = {};
        this._newClosedDocumentIds = {};

        this._initActiveDocumentID();
        this._resetOpenDocumentIDs()
            .then(function () {
                // make sure that openDocumentsChanged fires once on startup, even
                // if there are no open documents
                this._handleOpenDocumentsChange();
            }.bind(this))
            .done();


        generator.onPhotoshopEvent("imageChanged", this._handleImageChanged.bind(this));
    }
function DocumentManager(generator, config, logger, options) {
        EventEmitter.call(this);
        
        this._generator = generator;
        this._config = config;
        this._logger = logger;
        
        options = options || {};
        this._getDocumentInfoFlags = options.getDocumentInfoFlags;
        this._clearCacheOnChange = options.clearCacheOnChange;

        this._documents = {};
        this._documentDeferreds = {};
        this._documentChanges = {};

        this._openDocumentIds = {};
        this._newOpenDocumentIds = {};
        this._newClosedDocumentIds = {};

        this._initActiveDocumentID();
        this._resetOpenDocumentIDs()
            .then(function () {
                // make sure that openDocumentsChanged fires once on startup, even
                // if there are no open documents
                this._handleOpenDocumentsChange();
            }.bind(this))
            .done();


        generator.onPhotoshopEvent("imageChanged", this._handleImageChanged.bind(this));
    }
function DocumentManager ( generator , config , logger , options ) { EventEmitter . call ( this ) ; this . _generator = generator ; this . _config = config ; this . _logger = logger ; options = options || { } ; this . _getDocumentInfoFlags = options . getDocumentInfoFlags ; this . _clearCacheOnChange = options . clearCacheOnChange ; this . _documents = { } ; this . _documentDeferreds = { } ; this . _documentChanges = { } ; this . _openDocumentIds = { } ; this . _newOpenDocumentIds = { } ; this . _newClosedDocumentIds = { } ; this . _initActiveDocumentID ( ) ; this . _resetOpenDocumentIDs ( ) . then ( function ( ) { // make sure that openDocumentsChanged fires once on startup, even // if there are no open documents this . _handleOpenDocumentsChange ( ) ; } . bind ( this ) ) . done ( ) ; generator . onPhotoshopEvent ( "imageChanged" , this . _handleImageChanged . bind ( this ) ) ; }
The DocumentManager provides a simple interface for requesting and maintaining
up-to-date Document objects from Photoshop.

Emits "openDocumentsChanged" event when the set of open documents changes with
the following parameters:
1. @param {Array.<number>} IDs for the set of currently open documents
2. @param {Array.<number>} IDs for the set of recently opened documents
3. @param {Array.<number>} IDs for the set of recently closed documents

Emits "activeDocumentChanged" event when the currently active document changes
with the follwing parameter:
1. @param {?number} ID of the currently active document, or null if there is none

@constructor
@param {Generator} generator
@param {object} config
@param {Logger} logger
@param {object*} options runtime options:
getDocumentInfoFlags: object, key documented at getDocumentInfo
clearCacheOnChange: bool, removes the document from the cache on
change instead of updating it and sending a change event
The DocumentManager provides a simple interface for requesting and maintaining up - to - date Document objects from Photoshop .