Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Promises A+ Compliance #3699

Closed
wants to merge 5 commits into from
Closed

Commits on Aug 25, 2013

  1. Configuration menu
    Copy the full SHA
    9b94169 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9270050 View commit details
    Browse the repository at this point in the history
  3. feat(mocks): make $timeout#flush throw an exception when empty

    When calling $timeout.flush with or without a delay an exception should
    be thrown if there is nothing to be flushed.
    
    This prevents tests from flushing stuff unnecessarily.
    
    BREAKING CHANGE: calling $timeout.flush(delay) when there is no task to be flushed
    within the delay throws an exception now.
    
    Please adjust the delay or remove the flush call from your tests as the exception
    is a signed of a programming error.
    IgorMinar committed Aug 25, 2013
    Configuration menu
    Copy the full SHA
    cbf06a5 View commit details
    Browse the repository at this point in the history
  4. fix(mocks): $timeout#flush should not update time when empty

    When $timeout#flush is called with a delay and no task can be flushed within that
    delay, the current time should not be updated as that gets the mock into an inconsistent
    state.
    
    BREAKING CHANGE: if a tests was written around the buggy behavior the delays might be off now
    
    This would typically not be a problem, but because of the previous breaking change in
    $timeout.flush, the combination of two might be confusing and that's why we are documenting
    it.
    
    Old behavior:
    
    ```
    doSomething(); //schedules task to execute in 500ms from now
    doOtherStuff(); //schedules task to execute in 600ms from now
    
    try {
      $timeout.flush(300); // throws "no task to be flushed" exception
    } catch(e) {};
    $time.flush(200); //flushes only doSomething() task
    ```
    
    New behavior:
    
    ```
    doSomething(); //schedules task to execute in 500ms from now
    doOtherStuff(); //schedules task to execute in 600ms from now
    
    try {
      $timeout.flush(300); // throws "no task to be flushed" exception
    } catch(e) {};
    $time.flush(200); // throws "no task to be flushed" exception again
                      // because previous exception didn't move the time forward
    ```
    
    Fixed test:
    
    ```
    doSomething(); //schedules task to execute in 500ms from now
    doOtherStuff(); //schedules task to execute in 600ms from now
    
    try {
      $timeout.flush(300); // throws "no task to be flushed" exception
    } catch(e) {};
    $time.flush(500); // flushes only doSomething() task
    ```
    IgorMinar committed Aug 25, 2013
    Configuration menu
    Copy the full SHA
    42af8ea View commit details
    Browse the repository at this point in the history
  5. feat(Scope): async auto-flush $evalAsync queue when outside of $digest

    This change causes a new $digest to be scheduled in the next tick if
    a task was was sent to the $evalAsync queue from outside of a $digest
    or an $apply.
    
    While this mode of operation is not common for most of the user code,
    this change means that $q promises that utilze $evalAsync queue to
    guarantee asynchronicity of promise apis will now also resolve outside
    of a $digest, which turned out to be a big pain point for some developers.
    
    The implementation ensures that we don't do more work than needed and
    that we coalese as much work as possible into a single $digest.
    
    The use of $browser instead of setTimeout ensures that we can mock out
    and control the scheduling of "auto-flush", which should in theory
    allow all of the existing code and tests to work without negative
    side-effects.
    
    Closes angular#3539
    Closes angular#2438
    IgorMinar committed Aug 25, 2013
    Configuration menu
    Copy the full SHA
    9dada81 View commit details
    Browse the repository at this point in the history