Skip to content

vue-router Data Store #257

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
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions active-rfcs/0000-data-store.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
- Start Date: 2021-01-24
- Target Major Version: 3.4.9
- Reference Issues: https://github.com/vuejs/vue-router/issues/3452
- Implementation PR: (leave this empty)

# Summary
Maintain a store by history state key. Can be used to save something.


# Basic example

[Online Demo](https://hezedu.github.io/SomethingBoring/vue-router-positionstore-memory-leak/pr-demo.html#/)
# Motivation

Unlike [window.history](https://developer.mozilla.org/en-US/docs/Web/API/History), vue-router has no API to change history.state.

But sometimes we need it to store some unique keys, like the `positionStore`. <br>
So I replaced `positionStore` with `dataStore`. This way you can store more things. <br>

# Detailed design

<b>Fixed:</b> [#3445: vue-router positionStore memory leak](https://github.com/vuejs/vue-router/issues/3445)

<b>reconstruct:</b> `util/state-key`

## New API
### router.setData(key, data)
- `key` ___string___
- `data` ___any___
### router.getData(key)
- `key` ___string___
- Returns: ___any___
### router.removeData(key)
- `key` ___string___



# Adoption strategy
Expose three new APIs, And there is no need to develop `state` related APIs in the future.