简体   繁体   English

Firebase和Redux? 将收到的数据保存在Redux存储中

[英]Firebase and redux? Save received data in redux store

I'm having a problem with saving the data received from the firebase. 我在保存从Firebase接收的数据时遇到问题。

When I was fetching the data from backend with native http calls (I was using redux/redux saga for it) the data was stored correctly in the storage, so if user entered some other component and returned back to the listed data, there was no need to fetch the data once again from the server. 当我使用本地http调用从后端获取数据时(我使用的是redux / redux saga),数据已正确存储在存储中,因此,如果用户输入其他组件并返回到列出的数据,则不会需要再次从服务器获取数据。 It was saved inside redux store. 它已保存在redux商店中。

But since Im using firebase, if user navigates over my application and returns to the component which lists some data from the server, the same data is fetched every time. 但是由于Im使用Firebase,因此如果用户浏览我的应用程序并返回列出服务器中某些数据的组件,则每次都会提取相同的数据。 This is a huge issue. 这是一个巨大的问题。

Q : Is there some way to store the data received from firebase call in redux store? :有什么方法可以将从Firebase调用接收到的数据存储在redux存储中?

Of course, I don't want to loose the real-time database . 当然, 我不想丢失 实时数据库 This is a pure awesomeness, that user doesn't have to reload the page to update the content. 这纯粹是很棒的事情,用户不必重新加载页面即可更新内容。

Looking forward for any hint or suggestions. 期待任何提示或建议。 Maybe I don't even need redux for it? 也许我什至不需要redux? Maybe firebase provides some mechanism to deal with it? 也许firebase提供了一些机制来应对它? Thank u! 感谢你!

Found an outstanding library recently, which solves cases included in my question. 最近建立了一个出色的图书馆,可以解决我的问题中的案例。 If anyone would ask for same thing in the future, here's the library: 如果将来有人要问同样的事情,这里是图书馆:

https://github.com/prescottprue/react-redux-firebase https://github.com/prescottprue/react-redux-firebase

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM