Coder Social home page Coder Social logo

Comments (5)

radex avatar radex commented on May 23, 2024

Sure, I think using MobX as a local state management system + WatermelonDB as the database should work just fine.

from watermelondb.

sbtly avatar sbtly commented on May 23, 2024

Interesting!
But wouldn't it cause related component to be updated twice every time some value changes?

for example,

// mobX part
@observable myColor

// watermelon part
...color.value = myColor...

user changes @observable myColor ->
mobX will update related component ->
mobX's changed observable value will update watermelon's color.value ->
watermelon will update related component again

This is what I think might happen when using MobX and WatermelonDB together.
Is this wrong or is this perfectly okay?

from watermelondb.

radex avatar radex commented on May 23, 2024

I don't get it. Why do you want to use both MobX and Watermelon to manage the same data? I get using MobX as local-state-only library, but why go through MobX to modify persistent data?

from watermelondb.

sbtly avatar sbtly commented on May 23, 2024

oh, now I see.
This is my first time trying backend myself.
So I got all mixed up about how to deal with data.

I'll try using MobX + WatermelonDB then!
Thanks for the quick reply :)

from watermelondb.

awgv avatar awgv commented on May 23, 2024

This thread is the first search result, so I’ll post it here. Unless I’m missing something—withObservables() can’t be combined with observer() HOC—when you have multiple HOCs, you’re supposed to apply observer() first, but observer() memoizes components, and you should memoize after withObservables(). If you apply observer() last, an error is thrown; if you apply observer() first, everything is now memoized, and changes to WatermelonDB models don’t rerender components. As far as I can tell, there’s no way to work around this—at least not in a way that’s mentally tolerable.

I don’t know how any of this work, but perhaps, it’ll become possible when and if WatermelonDB switches to a hook. I’d also like someone to confirm this, and until someone does, it would be best to take this message with a grain of salt and set up a basic WatermelonDB+MobX project to see the issues for yourself.

from watermelondb.

Related Issues (20)

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.