-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Added support for vuex-persist #102
Conversation
Codecov Report
@@ Coverage Diff @@
## master #102 +/- ##
===========================================
- Coverage 96.32% 84.67% -11.65%
===========================================
Files 9 9
Lines 136 124 -12
Branches 15 13 -2
===========================================
- Hits 131 105 -26
- Misses 4 16 +12
- Partials 1 3 +2
Continue to review full report at Codecov.
|
* ALso fixed definition
it would be great if we could get this support |
Can this be merged in? |
... | ||
|
||
-- @Module({ dynamic: true, store: store, name: 'mm' }) | ||
++ @Module({ dynamic: true, store: store, name: 'mm', preserveState: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a diff of a diff... maybe a bad merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
package.json
Outdated
@@ -62,7 +63,8 @@ | |||
"typescript": "^3.2.2", | |||
"vue": "^2.6.6", | |||
"vuepress": "^0.14.8", | |||
"vuex": "^3.1.0" | |||
"vuex": "^3.1.0", | |||
"vuex-persist": "^2.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is great, but I think tying this project to vuex-persist
is an unnecessary coupling.
The change can very well live without any reference to vuex-persist
and merely serve as an additional ability to set the preserveState
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, it's development only. So will only be installed once you want to develop it. Since I wrote integration tests between the two libraries. How would I go ahead and test it without the library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kapulara I'm not sure, but you could install it as a peer dependency perhaps?
I'm also interesting in using the power of both tools 😃 Can't wait to see that merged and released 👍 |
Can this be merged in please? |
I am still apprehensive of shoving vuex-persist down the throats of
everyone who uses vuex-module-decorators
While I am proud of my own work on vuex-persist, many people use the
alternate library vuex-persistedstate too. I would not want to drag them
just because one of my libraries forces using another.
…On Fri 26 Apr, 2019, 3:20 PM Bart van Vliet, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In package.json
<#102 (comment)>
:
> @@ -62,7 +63,8 @@
"typescript": "^3.2.2",
"vue": "^2.6.6",
"vuepress": "^0.14.8",
- "vuex": "^3.1.0"
+ "vuex": "^3.1.0",
+ "vuex-persist": "^2.0.0"
First of all, it's development only. So will only be installed once you
want to develop it. Since I wrote integration tests between the two
libraries. How would I go ahead and test it without the library?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#102 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKD7SV3PTQGTSWI7MGOHPTPSLF5BANCNFSM4G4ZDJGA>
.
|
@championswimmer what would be the more appropriate way? Having kind of interfaces to plugin any persisting module behind the scene? By the way, do you currently have a project where you combine both Thanks again for your work! |
@championswimmer If that's the case, then please make it possible to use dynamic modules in combination with vuex-persist. This does currently not work. |
You are right about this, however all of the wording I did in the documentation I referenced it with "e.g" so not really feeling like shoving it down everyone. Just giving an example in how this would be used. Also I added it as development dependency so It's only required for development and wont be installed with the production flag. The only reason I installed it was because I wanted to make sure it works. If you feel like it should be removed and have this as a "preserveState" functionality just let me know. I'll change the pull request to match that instead. However I wouldn't know how to test "preserveState". Thanks for all of the hard work you put into this library. |
I'm still wondering what would you recommend @championswimmer? From what I understand this PR uses Thank you, |
Would love to see this PR merged, or at the very least see |
What I could do is remove the tests (@championswimmer if that's ok) So we can merge this finally. |
We can keep vuex-persist in peer dependencies and merge this.
…On Wed 10 Jul, 2019, 9:45 PM Bart van Vliet, ***@***.***> wrote:
Would love to see this PR merged, or at the very least see @module
support preserveState
What I could do is remove the tests ***@***.***
<https://github.com/championswimmer> if that's ok)
So we can merge this finally.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#102?email_source=notifications&email_token=AAKD7SV3IWVMRJ5BBVKCTRDP6ZC7BA5CNFSM4G4ZDJGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZUV6DY#issuecomment-510222095>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKD7SRBQQJSBFMMORTJWPLP6ZC7BANCNFSM4G4ZDJGA>
.
|
@championswimmer added it as peer dependency but now build seems to be failing since tests cannot be run. How would you like to approach? |
Sorry, but I don't get it. Why not adding vuex-persist as devDependency? This way, vuex-persist is only required for development of vuex-module-decoratos itself and not for the actual users who use the library. Users of vuex-module-decorators don't have to use vuex-persist nor do they have to install it in any way, because it's not in the dependency list. You did an awesome job with both libraries @championswimmer , kudos for that. Let's now bring them together with this fix. :-) |
Hi guys. I've started working on a project where I required these changes. So I published the changes to a new public package which everyone else can use. @championswimmer I will deprecate the package if you approve this merge request. Package: @bartvanvliet/vuex-module-decorators |
@Kapulara i tried your package, but doesn't seem to be working for me FYI const vuexLocal = new VuexPersistence<ClientState>({
strictMode: process.env.NODE_ENV === 'development',
storage: window.sessionStorage
})
const storeOptions: StoreOptions<ClientState> = {
plugins: [vuexLocal.plugin],
strict: process.env.NODE_ENV === 'development'
}
@Module({
dynamic: true,
namespaced: true,
name: Namespaces.ThingModule,
stateFactory: true,
store: store,
preserveState: true
})
export class ThingModule extends VuexModule {
myThings: string[] = []
// ...
}
|
@championswimmer what's the current progress? |
I've used this workaround: https://stackoverflow.com/questions/55843052/vuex-not-loading-module-decorated-with-vuex-module-decorators Seems to work. |
@webcoderkz that's not a workaround. That answer is using a static module; not a dynamic module. |
@mrijken won't it work with dynamic modules in the future? |
@webcoderkz only when this PR is merged. |
Why @championswimmer won't merge this PR? |
Signed-off-by: Arnav Gupta <[email protected]>
I was able to preserve the state of dynamic modules with vuex-persistedstate robinvdvleuten/vuex-persistedstate#225 |
Hey @championswimmer, when can we excpect the merge to occur ? |
@championswimmer any chance for this to be merged this year? |
mabe I have a solution for this,I write a vuex plugin by hijacking the store.registerModule in vuex
|
need the travis ci to pass, before merging :( |
Can somebody merge it please? |
Signed-off-by: Arnav Gupta <[email protected]>
…ecorators into pr_102
Signed-off-by: Arnav Gupta <[email protected]>
Hello,
So when researching this I found this commit:
vuejs/vuex#837
It essentially allows you to preserve the state when registering a module dynamically.
Right now it just uses the default values and overrides the state. (which makes you unable to use vuex-persist for example. Might be others as well)
So now you can add
preserveState
to@Module
as a option.Also took the test from #47 hope you don't mind 😉 @JohnCampionJr
I believe this PR will fix/close:
#44
#46
#47
... maybe others
Thanks,
Bart