Skip to content

Replace 'fetch' API with isomorphic request solution that uses XHR for progress UI #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jonsherrard opened this issue Jan 23, 2017 · 4 comments

Comments

@jonsherrard
Copy link
Contributor

When the Tapestry client JS bundle picks up routing and navigation, we lose any visual feedback on the progress of a page load.

The current implementation of Fetch does not have progress events, the idea is that on-the-fly calculation will be done using streams in the future.

In the meantime we will have to use an XHR solution that an onprogress even on the client.

https://github.com/matthewwithanm/httpplease.js Seems like reasonable candidate - IE9 compatibility etc, haven't vetted it heavily though.

@jonsherrard
Copy link
Contributor Author

This may be a 🌶

@thomasdigby
Copy link
Contributor

axios looks a good bet, onDownloadProgress will return us a progress event. Here's an example.

How would we expose this progress event to the user? via the config? I'm struggling to understand how we'd render and update a component alongside the static main view. Whaddaya thoughts?

@jonsherrard
Copy link
Contributor Author

jonsherrard commented Mar 3, 2017

The way I see it they'd provide a custom progress loader a-la github.

However we could emit the event via a proxy object on window

componentDidMount() {
  window.tapestryDataLoader.on('onprogress', (percentageComplete) => {
    this.setState({
      fetchProgress: percentageComplete
    })
  })
}

or via component they supply:

import DefaultProgress from './default-progress'

const Loader = loadContext.customProgress || DefaultProgress 

class App extends Component {
   render(
      <div>
          <Loader value={onDownloadProgress} /> 
          <Router>
              // All your app stuff
          </Router>
      </div>
   )
}

Maybe we could start with an event emitter proxy for a first version. Does that make sense and seem feasible?

@thomasdigby thomasdigby modified the milestone: v2 Mar 22, 2017
@thomasdigby
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants