From e05ac24cb76dc66cb879ba8e078f71e8ada3f0e1 Mon Sep 17 00:00:00 2001 From: Du Wei Date: Sun, 24 Jan 2021 10:53:23 +0800 Subject: [PATCH] Create 0000-data-store.md --- active-rfcs/0000-data-store.md | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 active-rfcs/0000-data-store.md diff --git a/active-rfcs/0000-data-store.md b/active-rfcs/0000-data-store.md new file mode 100644 index 00000000..d9178aeb --- /dev/null +++ b/active-rfcs/0000-data-store.md @@ -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`.
+So I replaced `positionStore` with `dataStore`. This way you can store more things.
+ +# Detailed design + +Fixed: [#3445: vue-router positionStore memory leak](https://github.com/vuejs/vue-router/issues/3445) + +reconstruct: `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. + +