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

Support redux enhancer #258

Closed
jindada opened this issue Nov 9, 2016 · 12 comments
Closed

Support redux enhancer #258

jindada opened this issue Nov 9, 2016 · 12 comments

Comments

@jindada
Copy link
Contributor

jindada commented Nov 9, 2016

我刷新页面的时候 state变成了初始值 请问dva有store持久化的机制吗 类似于redux-persisit这种

@sorrycc
Copy link
Member

sorrycc commented Nov 9, 2016

目前不支持 redux 的 enhancer,所以用不了 redux-persist 。

@jindada
Copy link
Contributor Author

jindada commented Nov 9, 2016

有其他替代的解决方案吗? 比我我登录之后的用户信息 一刷新就没有了

@sorrycc
Copy link
Member

sorrycc commented Nov 9, 2016

const app = dva({
  onStateChange() {
    save(app._store.getState());
  },
});

试试这样,有点难看,后续会把 state 传给 onStateChange 。

@jindada
Copy link
Contributor Author

jindada commented Nov 9, 2016

image
save未定义 需要引入什么吗

@sorrycc
Copy link
Member

sorrycc commented Nov 9, 2016

save 需要你自己实现的。

@jindada
Copy link
Contributor Author

jindada commented Nov 9, 2016

save可以实现 state-> 持久化state , 那怎么持久化state-> state 如何去实现那 ?还是dva自动就同步了

@sorrycc
Copy link
Member

sorrycc commented Nov 9, 2016

const app = dva({
  initialState: savedState,
});

@jindada
Copy link
Contributor Author

jindada commented Nov 9, 2016

好吧 先这么用吧 期待dva尽快支持持久化

@liSong5713
Copy link

我也是遇到同样问题,目前都是保存到本地,我试下sorrycc的 推荐的方式

@sorrycc sorrycc changed the title dva有store持久化的机制吗 支持 redux enhancer Nov 15, 2016
@sorrycc sorrycc changed the title 支持 redux enhancer Support redux enhancer Nov 18, 2016
This was referenced Nov 18, 2016
@FourKnife
Copy link

save也是要保存到本地吗?

@huangronggod
Copy link

请问,如何有选择性的持久性store呢,比如我只想某几个state变化的时候,我才存储,这样存储的store,就不会太大@sorrycc

@nihgwu
Copy link
Member

nihgwu commented May 18, 2017

@huangronggod 自己写存储策略

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

No branches or pull requests

6 participants