Search code examples
pythonwebserverreactive-programmingmessagingstate-management

Are there reactive state libraries like Mobx for Python?


I'm looking for reactive state libraries like Mobx for Python, i.e. on server-side rather than client-side of a web application.

Mobx is similar to classic reactive libraries like RxPY, but has a different focus: It is not so much avout the low-level event dispatching, but reacting on data changes, recalculating derived values (but only those affected, and being lazy on non-observed dependent values). And Mobx determines dependencies of calculated values automatically.

Also, the Vue framework has such functionality built-in, with an even better syntax, with the upside (as well as downside) by being closely tied to the framework.

Alas, both are JavaScript and targeted at client-side / user interface.

So my specific questions are:

  • Are there similar reactive state libraries for Python?
  • Do these provide integration for storing/observing data in files?
    • (This would essentially be an inotify-based build system, but more fine-grained and more flexible.)
  • Do these provide integration with relational databases?
    • (Yes, there is a conceptual gap to be bridged, and it probably works only as long a single server instance accesses the database. It would still be very useful for wide range of applications.)
  • Do these provide integration with webserver frameworks?
    • (i.e. received HTTP requests trigger state changed and reclaculations, some calculated values are JSON structures which are observed by the client through web sockets, long polling or messaging systems.)

Solution

  • I did one. It's called MoPyX. It's toolkit independent so you can just observe objects. But is geared towards UIs.

    See: https://github.com/germaniumhq/mopyx

    PySide2 demo: https://github.com/germaniumhq/mopyx-sample