Git Product home page Git Product logo

Comments (3)

FunnySaltyFish avatar FunnySaltyFish commented on May 29, 2024

是的,目前不会监听数据的变化,目前我的解决方案是把类似的状态放到全局,各处引用同一个state,这样修改它的值所有地方都会同步更新,代码类似于 这里

当然,如果您有更好的方案(比如说我之前设想过的在 DataSaverInterface 中添加类似 fun notifyDataChanged(key: String, newData: T): Flow<T>,使数据变化时能被通知),也欢迎讨论和 PR !

from composedatasaver.

cy745 avatar cy745 commented on May 29, 2024

的确设置成全局的话能省很多工作,或许可以内部维护一个存放State的Map,添加一个参数控制该State是否全局唯一,根据参数确保这个Key只会创建一个State就行

但实际还是没有监听数据变化的逻辑,如果有其他更新数据的源,比如直接操作SharedPreference的情况

我觉得这个全局唯一State的这个逻辑算是另外一个改进的方向,我先试试弄这个监听数据变化的

from composedatasaver.

FunnySaltyFish avatar FunnySaltyFish commented on May 29, 2024

五个月后,这个库加入了简单的支持(虽然你早已经自己实现了~)。此 Issue 关闭了,有好的想法的话欢迎之后继续交流~

from composedatasaver.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.