angular2-polyfill
angular2-polyfill copied to clipboard
Create shims for `setTimeout`, `Promise`, `setInterval`, ...
In Angular1, you would have to $scope.$apply when using setTimeout, setInterval, etc. This is not necessary anymore in Angular2 because the entire change detection changed.
In order for easier migration later on, it might be nice to provide shims for this.
import {setTimeout, setInterval} from 'angular2-polyfill/ng2-shims`;
Where setTimeout basically is an alias for $timeout.
Benefit
When migrating to Angular2, you would only have to remove the imports at the top and nothing else changes.
List of shims
-
window→$window -
setTimeout→$timeout -
setInterval→$interval -
Promise→$q(tweaked version of $q to make it more Promise compatible)
@jvandemo suggested to work with zone.js in order to apply the root scope when the async task is executed. Probably with the afterTask hook. Not sure though, not a zone expert :).