Comments (3)
是的,目前不会监听数据的变化,目前我的解决方案是把类似的状态放到全局,各处引用同一个state,这样修改它的值所有地方都会同步更新,代码类似于 这里。
当然,如果您有更好的方案(比如说我之前设想过的在 DataSaverInterface
中添加类似 fun notifyDataChanged(key: String, newData: T): Flow<T>
,使数据变化时能被通知),也欢迎讨论和 PR !
from composedatasaver.
的确设置成全局的话能省很多工作,或许可以内部维护一个存放State的Map,添加一个参数控制该State是否全局唯一,根据参数确保这个Key只会创建一个State就行
但实际还是没有监听数据变化的逻辑,如果有其他更新数据的源,比如直接操作SharedPreference的情况
我觉得这个全局唯一State的这个逻辑算是另外一个改进的方向,我先试试弄这个监听数据变化的
from composedatasaver.
五个月后,这个库加入了简单的支持(虽然你早已经自己实现了~)。此 Issue 关闭了,有好的想法的话欢迎之后继续交流~
from composedatasaver.
Related Issues (6)
- No source code and comments when implementing by jitpack HOT 1
- 感谢,我在网上想找到这个 HOT 6
- 使用MMKV,但是compose preview提示先初始化MMKV HOT 4
- 有写入的序列化,怎么没有读取的序列化呢? HOT 2
- 再提个建议 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from composedatasaver.