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

New feature: Data Store(before PR) #3452

Closed
hezedu opened this issue Jan 22, 2021 · 3 comments
Closed

New feature: Data Store(before PR) #3452

hezedu opened this issue Jan 22, 2021 · 3 comments

Comments

@hezedu
Copy link

hezedu commented Jan 22, 2021

What problem does this feature solve?

#3445: vue-router positionStore memory leak

reconstruct util/state-key

used window.performance.now() as the state key will reset when localtion reload, It may conflict with other hisotories

What does the proposed API look like?

router.setData(key, data)

  • key string
  • data any

router.getData(key)

  • key string
  • Returns: any

router.removeData(key)

  • key string

Online Demo:

https://hezedu.github.io/SomethingBoring/vue-router-positionstore-memory-leak/pr-demo.html#/

Why adding these new features?

Unlike window.history, vue-router has no API to change history.state.

But sometimes we need it to store some unique keys, like the positionStore.

So I replaced positionStore with dataStore. This way you can store more things.

And there is no need to develop state related APIs in the future.

@hezedu hezedu changed the title New feature: Data Store, And Expose ispop parameters(before PR) New feature: Data Store(before PR) Jan 23, 2021
@posva
Copy link
Member

posva commented Jan 23, 2021

That's a cool demo! Unfortunately, the router won't have an api to hold state like history.state, it has been discussed many times in different issues and in different routers.

The thing you are trying to improve in v3 is already improved in v4 by using history.state for both HTML5 history and hash history but that won't be possible in v3

The isPop is something that I plan on introducing through an RFC for Vue Router 4. It might be backported to v3 after that

@hezedu
Copy link
Author

hezedu commented Jan 23, 2021

isPop I have already cut off. Because I can distinguish back , forword, repalce or push in more detail.
This will be another PR (if this PR passes)

@posva
Copy link
Member

posva commented Jan 23, 2021

Closing in favor of #3453 although it still needs to go through an RFC

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

No branches or pull requests

2 participants