Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

State for last update time #1703

Closed
shuding opened this issue Dec 11, 2021 · 1 comment
Closed

State for last update time #1703

shuding opened this issue Dec 11, 2021 · 1 comment
Labels
feature request New feature or request

Comments

@shuding
Copy link
Member

shuding commented Dec 11, 2021

It would be helpful to introduce a new state updatedAt, which is a timestamp representing the last time we get the data from the fetcher or mutator.

Use Case

The typical use case for this feature will be showing a last refreshed time of the data in the UI which is critical for its realtimeness.

Without this new state one can only implement it with an effect hook to monitor the data change. However due to the deep comparison of SWR that doesn't work when data remains the same.

@icyJoseph
Copy link
Contributor

icyJoseph commented Dec 13, 2021

updatedAt then should be equal to Date.now right after the concurrent promise for this key resolves?

      startAt = CONCURRENT_PROMISES_TS[key]
      newData = await CONCURRENT_PROMISES[key]
      newState.updatedAt = Date.now()

Of course keeping the updatedAt as part of the tracked dependencies state.

And is anyone actively working on this?

Edit: I now have some local changes with this change.

@shuding shuding added the feature request New feature or request label Dec 23, 2021
@vercel vercel locked and limited conversation to collaborators Dec 20, 2022
@koba04 koba04 converted this issue into discussion #2319 Dec 20, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants