|
1181 | 1181 | recursiveAction = function (state1) { |
1182 | 1182 | action(state1, function (state2, dueTime1) { |
1183 | 1183 | var isAdded = false, isDone = false, |
1184 | | - d = scheduler[method].call(scheduler, state2, dueTime1, function (scheduler1, state3) { |
| 1184 | + d = scheduler[method](state2, dueTime1, function (scheduler1, state3) { |
1185 | 1185 | if (isAdded) { |
1186 | 1186 | group.remove(d); |
1187 | 1187 | } else { |
|
1776 | 1776 |
|
1777 | 1777 | Enumerable.prototype.concat = function () { |
1778 | 1778 | var sources = this; |
1779 | | - return new AnonymousObservable(function (observer) { |
1780 | | - var e; |
1781 | | - try { |
1782 | | - e = sources[$iterator$](); |
1783 | | - } catch (err) { |
1784 | | - observer.onError(err); |
1785 | | - return; |
1786 | | - } |
| 1779 | + return new AnonymousObservable(function (o) { |
| 1780 | + var e = sources[$iterator$](); |
1787 | 1781 |
|
1788 | | - var isDisposed, |
1789 | | - subscription = new SerialDisposable(); |
| 1782 | + var isDisposed, subscription = new SerialDisposable(); |
1790 | 1783 | var cancelable = immediateScheduler.scheduleRecursive(function (self) { |
1791 | | - var currentItem; |
1792 | 1784 | if (isDisposed) { return; } |
1793 | | - |
1794 | 1785 | try { |
1795 | | - currentItem = e.next(); |
| 1786 | + var currentItem = e.next(); |
1796 | 1787 | } catch (ex) { |
1797 | | - observer.onError(ex); |
1798 | | - return; |
| 1788 | + return o.onError(ex); |
1799 | 1789 | } |
1800 | 1790 |
|
1801 | 1791 | if (currentItem.done) { |
1802 | | - observer.onCompleted(); |
1803 | | - return; |
| 1792 | + return o.onCompleted(); |
1804 | 1793 | } |
1805 | 1794 |
|
1806 | 1795 | // Check if promise |
|
1810 | 1799 | var d = new SingleAssignmentDisposable(); |
1811 | 1800 | subscription.setDisposable(d); |
1812 | 1801 | d.setDisposable(currentValue.subscribe( |
1813 | | - observer.onNext.bind(observer), |
1814 | | - observer.onError.bind(observer), |
1815 | | - function () { self(); }) |
| 1802 | + function(x) { o.onNext(x); }, |
| 1803 | + function(err) { o.onError(err); }, |
| 1804 | + self) |
1816 | 1805 | ); |
1817 | 1806 | }); |
1818 | 1807 |
|
|
1824 | 1813 |
|
1825 | 1814 | Enumerable.prototype.catchError = function () { |
1826 | 1815 | var sources = this; |
1827 | | - return new AnonymousObservable(function (observer) { |
1828 | | - var e; |
1829 | | - try { |
1830 | | - e = sources[$iterator$](); |
1831 | | - } catch (err) { |
1832 | | - observer.onError(err); |
1833 | | - return; |
1834 | | - } |
| 1816 | + return new AnonymousObservable(function (o) { |
| 1817 | + var e = sources[$iterator$](); |
1835 | 1818 |
|
1836 | | - var isDisposed, |
1837 | | - lastException, |
1838 | | - subscription = new SerialDisposable(); |
1839 | | - var cancelable = immediateScheduler.scheduleRecursive(function (self) { |
| 1819 | + var isDisposed, subscription = new SerialDisposable(); |
| 1820 | + var cancelable = immediateScheduler.scheduleRecursiveWithState(null, function (lastException, self) { |
1840 | 1821 | if (isDisposed) { return; } |
1841 | 1822 |
|
1842 | | - var currentItem; |
1843 | 1823 | try { |
1844 | | - currentItem = e.next(); |
| 1824 | + var currentItem = e.next(); |
1845 | 1825 | } catch (ex) { |
1846 | | - observer.onError(ex); |
1847 | | - return; |
| 1826 | + return observer.onError(ex); |
1848 | 1827 | } |
1849 | 1828 |
|
1850 | 1829 | if (currentItem.done) { |
1851 | | - if (lastException) { |
1852 | | - observer.onError(lastException); |
| 1830 | + if (lastException !== null) { |
| 1831 | + o.onError(lastException); |
1853 | 1832 | } else { |
1854 | | - observer.onCompleted(); |
| 1833 | + o.onCompleted(); |
1855 | 1834 | } |
1856 | 1835 | return; |
1857 | 1836 | } |
|
1863 | 1842 | var d = new SingleAssignmentDisposable(); |
1864 | 1843 | subscription.setDisposable(d); |
1865 | 1844 | d.setDisposable(currentValue.subscribe( |
1866 | | - observer.onNext.bind(observer), |
1867 | | - function (exn) { |
1868 | | - lastException = exn; |
1869 | | - self(); |
1870 | | - }, |
1871 | | - observer.onCompleted.bind(observer))); |
| 1845 | + function(x) { o.onNext(x); }, |
| 1846 | + self, |
| 1847 | + function() { o.onCompleted(); })); |
1872 | 1848 | }); |
1873 | 1849 | return new CompositeDisposable(subscription, cancelable, disposableCreate(function () { |
1874 | 1850 | isDisposed = true; |
|
1879 | 1855 |
|
1880 | 1856 | Enumerable.prototype.catchErrorWhen = function (notificationHandler) { |
1881 | 1857 | var sources = this; |
1882 | | - return new AnonymousObservable(function (observer) { |
1883 | | - var e; |
1884 | | - |
1885 | | - var exceptions = new Subject(); |
1886 | | - |
1887 | | - var handled = notificationHandler(exceptions); |
1888 | | - |
1889 | | - var notifier = new Subject(); |
| 1858 | + return new AnonymousObservable(function (o) { |
| 1859 | + var exceptions = new Subject(), |
| 1860 | + notifier = new Subject(), |
| 1861 | + handled = notificationHandler(exceptions), |
| 1862 | + notificationDisposable = handled.subscribe(notifier); |
1890 | 1863 |
|
1891 | | - var notificationDisposable = handled.subscribe(notifier); |
1892 | | - |
1893 | | - try { |
1894 | | - e = sources[$iterator$](); |
1895 | | - } catch (err) { |
1896 | | - observer.onError(err); |
1897 | | - return; |
1898 | | - } |
| 1864 | + var e = sources[$iterator$](); |
1899 | 1865 |
|
1900 | 1866 | var isDisposed, |
1901 | 1867 | lastException, |
1902 | 1868 | subscription = new SerialDisposable(); |
1903 | 1869 | var cancelable = immediateScheduler.scheduleRecursive(function (self) { |
1904 | 1870 | if (isDisposed) { return; } |
1905 | 1871 |
|
1906 | | - var currentItem; |
1907 | 1872 | try { |
1908 | | - currentItem = e.next(); |
| 1873 | + var currentItem = e.next(); |
1909 | 1874 | } catch (ex) { |
1910 | | - observer.onError(ex); |
1911 | | - return; |
| 1875 | + return o.onError(ex); |
1912 | 1876 | } |
1913 | 1877 |
|
1914 | 1878 | if (currentItem.done) { |
1915 | 1879 | if (lastException) { |
1916 | | - observer.onError(lastException); |
| 1880 | + o.onError(lastException); |
1917 | 1881 | } else { |
1918 | | - observer.onCompleted(); |
| 1882 | + o.onCompleted(); |
1919 | 1883 | } |
1920 | 1884 | return; |
1921 | 1885 | } |
|
1928 | 1892 | var inner = new SingleAssignmentDisposable(); |
1929 | 1893 | subscription.setDisposable(new CompositeDisposable(inner, outer)); |
1930 | 1894 | outer.setDisposable(currentValue.subscribe( |
1931 | | - observer.onNext.bind(observer), |
| 1895 | + function(x) { o.onNext(x); }, |
1932 | 1896 | function (exn) { |
1933 | | - inner.setDisposable(notifier.subscribe(function(){ |
1934 | | - self(); |
1935 | | - }, function(ex) { |
1936 | | - observer.onError(ex); |
| 1897 | + inner.setDisposable(notifier.subscribe(self, function(ex) { |
| 1898 | + o.onError(ex); |
1937 | 1899 | }, function() { |
1938 | | - observer.onCompleted(); |
| 1900 | + o.onCompleted(); |
1939 | 1901 | })); |
1940 | 1902 |
|
1941 | 1903 | exceptions.onNext(exn); |
1942 | 1904 | }, |
1943 | | - observer.onCompleted.bind(observer))); |
| 1905 | + function() { o.onCompleted(); })); |
1944 | 1906 | }); |
1945 | 1907 |
|
1946 | 1908 | return new CompositeDisposable(notificationDisposable, subscription, cancelable, disposableCreate(function () { |
|
1962 | 1924 | }; |
1963 | 1925 |
|
1964 | 1926 | var enumerableOf = Enumerable.of = function (source, selector, thisArg) { |
1965 | | - selector || (selector = identity); |
| 1927 | + if (selector) { |
| 1928 | + var selectorFn = bindCallback(selector, thisArg, 3); |
| 1929 | + } |
1966 | 1930 | return new Enumerable(function () { |
1967 | 1931 | var index = -1; |
1968 | 1932 | return new Enumerator( |
1969 | 1933 | function () { |
1970 | 1934 | return ++index < source.length ? |
1971 | | - { done: false, value: selector.call(thisArg, source[index], index, source) } : |
| 1935 | + { done: false, value: !selector ? source[index] : selectorFn(source[index], index, source) } : |
1972 | 1936 | doneEnumerator; |
1973 | 1937 | }); |
1974 | 1938 | }); |
|
8096 | 8060 | }; |
8097 | 8061 |
|
8098 | 8062 | var JoinObserver = (function (__super__) { |
8099 | | - |
8100 | 8063 | inherits(JoinObserver, __super__); |
8101 | 8064 |
|
8102 | 8065 | function JoinObserver(source, onError) { |
|
8114 | 8077 | JoinObserverPrototype.next = function (notification) { |
8115 | 8078 | if (!this.isDisposed) { |
8116 | 8079 | if (notification.kind === 'E') { |
8117 | | - this.onError(notification.exception); |
8118 | | - return; |
| 8080 | + return this.onError(notification.exception); |
8119 | 8081 | } |
8120 | 8082 | this.queue.push(notification); |
8121 | 8083 | var activePlans = this.activePlans.slice(0); |
|
8228 | 8190 |
|
8229 | 8191 | function observableTimerDateAndPeriod(dueTime, period, scheduler) { |
8230 | 8192 | return new AnonymousObservable(function (observer) { |
8231 | | - var count = 0, d = dueTime, p = normalizeTime(period); |
8232 | | - return scheduler.scheduleRecursiveWithAbsolute(d, function (self) { |
| 8193 | + var d = dueTime, p = normalizeTime(period); |
| 8194 | + return scheduler.scheduleRecursiveWithAbsoluteAndState(0, d, function (count, self) { |
8233 | 8195 | if (p > 0) { |
8234 | 8196 | var now = scheduler.now(); |
8235 | 8197 | d = d + p; |
8236 | 8198 | d <= now && (d = now + p); |
8237 | 8199 | } |
8238 | | - observer.onNext(count++); |
8239 | | - self(d); |
| 8200 | + observer.onNext(count); |
| 8201 | + self(count + 1, d); |
8240 | 8202 | }); |
8241 | 8203 | }); |
8242 | 8204 | } |
|
0 commit comments