Changes between Version 13 and Version 14 of WebInspectorCodingStyleGuide


Ignore:
Timestamp:
May 27, 2015 10:58:42 AM (9 years ago)
Author:
Brian Burg
Comment:

Fix class skeleton to use ES6 class syntax; promise nit

Legend:

Unmodified
Added
Removed
Modified
  • WebInspectorCodingStyleGuide

    v13 v14  
    4646
    47471. Become __fulfilled__ by a **value**
    48 2. Become __rejected__ with an **exception**
     482. Become __rejected__ with an **Error instance** or by throwing an exception
    4949
    5050And, if you have a correctly implemented `then()` function, then fulfillment and rejection will compose just like their synchronous counterparts, with fulfillments flowing up a compositional chain, but being interrupted at any time by a rejection that is only handled by someone who declares they are ready to handle it.
     
    6666== New class skeleton
    6767
    68 The new Inspector object classes should have the following format:
     68New Inspector object classes use ES6 class syntax and should have the following format:
     69
     70{{{
     71WebInspector.NewObjectType = class NewObjectType extends WebInspector.Object {
     72    constructor(param)
     73    {
     74        WebInspector.Object.call(this);
     75       this._propertyName = param;
     76    }
     77
     78    // Public
     79
     80    get propertyName()
     81    {
     82        return this._propertyName;
     83    }
     84
     85    set propertyName(value)
     86    {
     87        this._propertyName = value;
     88        this.dispatchEventToListeners(WebInspector.NewObjectType.Event.PropertyWasChanged);
     89    }
     90
     91    publicMethod: function()
     92    {
     93        /* public methods called outside the class */
     94    }
     95
     96    // Protected
     97
     98    handleEvent: function(event)
     99    {
     100        /* delegate methods, event handlers, and overrides. */
     101    }
     102
     103    // Private
     104
     105    _privateMethod: function()
     106    {
     107        /* private methods are underscore prefixed */
     108    }
     109};
     110
     111WebInspector.NewObjectType.Event = {
     112    PropertyWasChanged: "new-object-type-property-was-changed"
     113};
     114
     115}}}
     116
     117== Old class skeleton
     118
     119Some existing Inspector object classes have not been converted to ES6 classes. The should conform to the following format:
    69120
    70121{{{