"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/event-kit/lib/disposable.js" (8 Mar 2017, 951 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 (function() {
    2   var Disposable, Grim;
    3 
    4   Grim = require('grim');
    5 
    6   module.exports = Disposable = (function() {
    7     Disposable.prototype.disposed = false;
    8 
    9     Disposable.isDisposable = function(object) {
   10       return typeof (object != null ? object.dispose : void 0) === "function";
   11     };
   12 
   13 
   14     /*
   15     Section: Construction and Destruction
   16      */
   17 
   18     function Disposable(disposalAction) {
   19       this.disposalAction = disposalAction;
   20     }
   21 
   22     Disposable.prototype.dispose = function() {
   23       if (!this.disposed) {
   24         this.disposed = true;
   25         if (typeof this.disposalAction === "function") {
   26           this.disposalAction();
   27         }
   28         this.disposalAction = null;
   29       }
   30     };
   31 
   32     return Disposable;
   33 
   34   })();
   35 
   36   if (Grim.includeDeprecatedAPIs) {
   37     Disposable.prototype.off = function() {
   38       Grim.deprecate("Use ::dispose to cancel subscriptions instead of ::off");
   39       return this.dispose();
   40     };
   41   }
   42 
   43 }).call(this);