taskease.js - Tasks: task #12107, Async/delay keyword (promises?)

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #12107: Async/delay keyword (promises?)

Submitter:  Mike Gerwitz <mikegerwitz>
Submitted:  Sun 10 Jun 2012 03:58:12 AM UTC
   
 
Should Start On:  Fri 01 Mar 2013 05:00:00 AM UTC Should be Finished on:  Mon 01 Jul 2013 04:00:00 AM UTC
Category:  Core Priority:  5 - Normal
Item Group:  Development Status:  None
Privacy:  Public Assigned to:  mikegerwitz
Percent Complete:  0% Open/Closed:  Open
Planned Release:  None
Keywords:  async

Sun 10 Jun 2012 03:58:12 AM UTC, original submission:  

Add an `async` or (less likely) `delay` keyword for method declarations. This would provide an alternative for:


    // conventional
    setTimeout( function()
    {
        // method body
    }, 25 );

    // Node.js
    process.nextTick( function()
    {
            // method body
    } );


The above code is very useful for:

  • Concurrent processing, especially important for environments like Node.js
  • In a browser environment, permits screen repainting to enhance user experience and prevent lockups


Both of the above code examples are unnecessary and messy if a keyword can satisfy this for us. The value returned from the method (since the call would become asynchronous) has yet to be determined. The options are:

  • Return a promise. This would provide a clean way to attach callbacks.
  • Return self and let the implementor define any necessary arguments to support callbacks.


The problem with returning a promise is that it'll prevent method chaining (unless we get creative or returned the object as a property, which can get ugly). The benefit is that it will reduce the code that the developer has to write. If a promise is provided, the developer may still choose to ignore it and instead implement a callback. Alternatively, we could add another ``promise`` keyword if the developer wishes for a promise to be returned, but that's getting messy (just throwing ideas out).

This idea will be explored further in the future. The goal is simply to (a) reduce unnecessary code and (b) encourage consistency. This will also provide a very basic way of making classes asynchronous, but that core concept will need additional consideration in the future.

Mike Gerwitz <mikegerwitz>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mikegerwitz (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code