Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26574] TiAPI: Implement set/clearImmediate

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2019-05-15T19:25:19.000+0000
Affected Version/sn/a
Fix Version/sRelease 8.1.0
ComponentsTiAPI
Labelsn/a
ReporterChristopher Williams
AssigneeChristopher Williams
Created2018-11-16T16:52:45.000+0000
Updated2019-05-28T13:57:41.000+0000

Description

setImmediate and clearImmediate are *sort of* like setTimeout/clearTimeout, but are supposed to be run after current I/O event callbacks are done. https://nodejs.org/api/timers.html#timers_setimmediate_callback_args Basically this is roughly like setTimeout(callback, 0); as a first stab, but should be run **before** and timeout callbacks. In effect, immediate, timers and ticks from process.nextTick are *sort of* like 3 separate priorities of timer queues, although at a lower level they have semantic/behavioral differences. ticks are right away and can cause infinite loops. immediate come next chance after I/O events callbacks. Then timers get fired when ready.

Comments

  1. Christopher Williams 2019-04-22

    https://github.com/appcelerator/titanium_mobile/pull/10863
  2. Christopher Williams 2019-05-15

    merged to master with a suite of unit tests to verify behavior.
  3. Samir Mohammed 2019-05-28

    *Closing ticket*, fix verified in SDK version 8.1.0.v20190524131922. *Tested with the following test case:*
       setImmediate((one, two, three) => {
          console.log(one);
          console.log(two);
          console.log(three);
       }, 1, '2', [ 3 ]);
       
       const immediate = setImmediate(() => {
          console.log('Should not be called as it is cleared below');
       });
       clearImmediate(immediate);
       
       
    Output:
       [INFO]   1
       [INFO]   2
       [INFO]   [3]
       
    Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/10863 *Test Environment*
       iphone 6s+ (12.2)
       Pixel XL (7.1.1)
       7.0.12-70X.4
       Operating System Name: Mac OS Mojave
       Operating System Version: 10.14.2
       Node.js Version: 8.11.3
       

JSON Source