Skip to content
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

Automatic Refreshing - Change Url on each request. #203

Open
luke-unifymonitor opened this issue May 3, 2018 · 2 comments
Open

Automatic Refreshing - Change Url on each request. #203

luke-unifymonitor opened this issue May 3, 2018 · 2 comments

Comments

@luke-unifymonitor
Copy link

Hi,

First, great library - thanks.

I'm using Automatic Refreshing and would like to update the url before the request is made.

Would it be possible to have the url returned as a function? For example....

connect(({ refreshInterval }) => {
    return {
      dataFetch: {
        url: (props) => { return `http://foo.com/${new Date().getTime()}` }, 
        refreshInterval: refreshInterval
      }
    }
  })

...or should I be attempting this some other way.

Many thanks.

@ryanbrainard
Copy link
Contributor

Interesting proposal. I guess this would just work if we always allowed url to be a function. I'm not sure I'd want to pass in the props because they'd be the old values, but at least in your case, a no-arg function would work too. Or do you need the props too?

@luke-unifymonitor
Copy link
Author

luke-unifymonitor commented May 4, 2018

Thanks Ryan.

My full use case is for a url which reads http://foo.com/{id}/{epoch} - The id would be the same across requests, but guess I would need that from the props. epoch would obviously change.

I thought this might do it...

connect((props) => {
    return {
      dataFetch: {
        url: (props) => { return `http://foo.com/${props.id}/${new Date().getTime()}` }, 
        refreshInterval: props.refreshInterval
      }
    }
  })

I didn't realise it would always result in the props having old values though. I'm not familiar with the code base - would that be a difficult thing to make happen?

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