Changes between Version 11 and Version 12 of WebInspectorCodingStyleGuide


Ignore:
Timestamp:
Aug 10, 2014 4:35:29 PM (7 years ago)
Author:
Brian Burg
Comment:

formatting

Legend:

Unmodified
Added
Removed
Modified
  • WebInspectorCodingStyleGuide

    v11 v12  
    4545[http://blog.parse.com/2013/01/29/whats-so-great-about-javascript-promises/ What's so great about Promises?] [http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/ The point of promises is to give us back functional composition] and error bubbling in the async world. They do this by saying that your functions should return a promise, which can do one of two things:
    4646
    47     Become __fulfilled__ by a **value**
    48     Become __rejected__ with an **exception**
     471. Become __fulfilled__ by a **value**
     482. Become __rejected__ with 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.
     
    6060* Use `.catch()` at the end of a chain to perform error handling.
    6161* To reject a promise, throw an `Error` instance or call the `reject` callback with an `Error` instance.
    62 * A `.catch()` block is considered resolved if it does not re-throw an Error instance. Re-throw if you want to log an error message and allow other parts of a chain (i.e, an API client) to handle an error condition.
    63 * Don't directly pass a promise's `resolve` function to Object.addEventListener, as it will leak the promise. Instead, use a single-fire WebInspector.EventListener object defined outside of the promise chain and connect it inside a `.then()` body. Inside the `.catch` block, disconnect the EventListener if necessary.
     62* A `.catch()` block is considered resolved if it does not re-throw an `Error` instance. Re-throw if you want to log an error message and allow other parts of a chain (i.e, an API client) to handle an error condition.
     63* Don't directly pass a promise's `resolve` function to `Object.addEventListener`, as it will leak the promise if the event never fires. Instead, use a single-fire `WebInspector.EventListener` object defined outside of the promise chain and connect it inside a `.then()` body. Inside the `.catch` block, disconnect the `EventListener` if necessary.
    6464
    6565== New class skeleton