You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 13, 2018. It is now read-only.
<inputvalue='{{query}}'><core-ajaxautourl='/search/{{query}}' lastresponse='{{response}}'></core-ajax>
Search results for <span>{{query}}</span><templaterepeat='{{searchResult in response.searchResults}}'><div>{{searchResult.title}}</div></template>
Imagine that the user first types [cat] into the input. The backend is very slow to respond to that search, and the user changes their query to [dog]. The backend responds quickly with [dog] results, then immediately afterwards it responds to the old [cat] query. The user of this app now sees that they have typed in [dog] but are seeing results for [cat].
This sort of race condition is very common, and very easy to write. Polymer can solve it transparently, and has done so in 0.5 by exposing the response value for the most recently made request (which is determined by the application's behavior and intent), rather than the most recently received response (which is determined by the backend, the network, and luck).
It's possible that I'm biased towards this solution due to the kinds of apps that I work on, but every time I've used a core-ajax element over the past year, this is the behavior that I wanted. Is there a use case where taking the most recently received response is better?
Consider this mini-app:
Imagine that the user first types [cat] into the input. The backend is very slow to respond to that search, and the user changes their query to [dog]. The backend responds quickly with [dog] results, then immediately afterwards it responds to the old [cat] query. The user of this app now sees that they have typed in [dog] but are seeing results for [cat].
This sort of race condition is very common, and very easy to write. Polymer can solve it transparently, and has done so in 0.5 by exposing the response value for the most recently made request (which is determined by the application's behavior and intent), rather than the most recently received response (which is determined by the backend, the network, and luck).
It's possible that I'm biased towards this solution due to the kinds of apps that I work on, but every time I've used a core-ajax element over the past year, this is the behavior that I wanted. Is there a use case where taking the most recently received response is better?
@cdata
Related: #14