javascript - RxJs Dealing with Exceptions without termination -


I'm not sure how well I am on it, if a specialist is able to improve it, then also Will be appreciated. My current understanding is that observations are lazy and do not produce prices until they subscribe. If an error occurs, the observation does not send any further value. In many cases this is not what is desired.

In the code sample given below, I am getting the weather for Perth and London and if there is an object pointing to the error then the error has occurred. It means very much that the error block will not be called on the customer, but the success will be and I have to see whether it is failing and changing the argument. What is the best way to do this ????

In addition, what zip operator waits for an object to order and return for an object, when a value of all is produced?

Code below:

  window.application = application || {}; Window.application.stocks = (function () {function getWeather (city, country) {return $ .ajaxAsObservable ({url: 'http://api.openweathermap.org/data/2.5/weather?q=' + city + (Country, country: temperature: v.data.main.temp}}}}}} var requests = Rx ('country, data type:' jsonp '}). Map (function (v) {return}. Obsevate Interwl (500) .meestamp () .map (function (v) {var perth = getWeather ('perth', 'au'); London meets London (London, 'Britain'); Observable.zip (Perth, London, Function (A, B) {Return: a: a, b: b, timestamp: v.timestamp, failure: wrong,};}). Try again (3). Hold (ra (Obsolete). & Gt; Failure to get temperature & lt; / li & gt; '). Annex (selector); return;} $ (' 
  • on: '+ data.timestamp +': + Data.a.city + '-' + Data. Atompecher + '& lt; / li & gt;'). Append To (selector); $ ('
  • on:' + data.timestamp For '+:' + data.b.city + '-' + data. B.temperature + '& lt; / Li & gt; '). Attachment (selector); }, Function (error) {selector.text (''); $ ('& Lt; li & gt; Error:' + Error + '') Attachment ('# Weather'); }, Function () {}); });

    You should change with .forEach () . Subscribe () Since one has a nickname for the second, and . Membership () More general and more obvious in this case.

    subscribe () can accept three functions as arguments onNext (first function), onError (second function, optional), onComplete (Third task, optional). Therefore, you probably want to receive membership, by providing another function to handle errors only. You do not need to insert a flag-like event for the .catch () operator.

    In addition, in the case of your specific use, where perth and London observations are conceptually independent (they have no dependency with each other) ), You .combineLatest () instead of .zip () . See for details on the difference between the two.

  • Comments

    Popular posts from this blog

    php - PDO bindParam() fatal error -

    logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

    java - Why my included JSP file won't get processed correctly? -