Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

[0.8 preview] lastresponse and lasterror introduce race conditions #77

@rictic

Description

@rictic

Consider this mini-app:

<input value='{{query}}'>
<core-ajax auto url='/search/{{query}}' lastresponse='{{response}}'></core-ajax>

Search results for <span>{{query}}</span>
<template repeat='{{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?

@cdata

Related: #14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions