membrane

https://github.com/phronmophobic/membrane
jlmr 2021-02-22T08:17:42.021100Z

@smith.adriane thanks for the reply. As I said its just an experiment for now, and I can see advantages (and disadvantages) to all the approaches you mention. Is there some mechanism in membrane to assist with: > put all state in a db, all effects update the db and the ui queries the db (with caching) when it needs to re-render. Where would I “hook into” the re-render process to trigger db queries?

phronmophobic 2021-02-22T08:36:19.021900Z

I just uploaded a proof of concept I made previously that integrates with datascript, https://github.com/phronmophobic/membrane-datascript

phronmophobic 2021-02-22T08:36:39.022400Z

it's a little messy since it's a just a proof of concept

phronmophobic 2021-02-22T08:37:06.022800Z

basically, every graphics backend has a run function. example usage: https://github.com/phronmophobic/membrane-datascript/blob/main/src/com/phronemophobic/membrane_datascript.clj#L141 )

phronmophobic 2021-02-22T08:38:17.023900Z

every backend's run function accepts a 0 arity function that should return a view when called. (for a more in-depth explanation see https://blog.phronemophobic.com/ui-model.html)

phronmophobic 2021-02-22T08:38:41.024600Z

this is the UI's view-function as mentioned in the design blog posts

phronmophobic 2021-02-22T08:39:22.025300Z

the view function will be called whenever it's time to rerender

phronmophobic 2021-02-22T08:40:55.025700Z

really, the short answer is that membrane doesn't have a framework that packages everything

phronmophobic 2021-02-22T08:46:56.026900Z

One of the problems membrane tries to address is that UI code tends to absorb the rest of your application. You end up with react-http, react-db, react-async, etc. Membrane tries to build user interfaces out of simpler pieces so that you don't need membrane specific libraries for non ui related code. If you need caching, you just use a caching library. If you need http, just use any http library.

phronmophobic 2021-02-22T09:05:29.027600Z

not sure if any of that makes sense

jlmr 2021-02-22T09:10:38.029500Z

Meaning the view function you provide should somehow incorporate the necessary queries, caching, etc. I guess that makes sense!

👍 1
jlmr 2021-02-22T09:11:47.031400Z

Am I right when this means I should not rely on the component/make-app function that membrane provides? Because that function has its own take on state management

👍 1
jlmr 2021-02-22T09:12:36.032300Z

Great, then I’m slowly getting there 🙂

phronmophobic 2021-02-22T09:12:54.032700Z

in the datascript example, you can see it has it's own version of make-app , https://github.com/phronmophobic/membrane-datascript/blob/main/src/com/phronemophobic/membrane_datascript.clj#L104

phronmophobic 2021-02-22T09:13:48.033500Z

you're doing great. I realize there's a pretty steep learning curve. Thanks for giving it a try 😄

🙌 1
phronmophobic 2021-02-22T09:14:23.034100Z

and make-app's responsibility is to build and return the 0 arity view function, https://github.com/phronmophobic/membrane-datascript/blob/main/src/com/phronemophobic/membrane_datascript.clj#L117

phronmophobic 2021-02-22T09:21:59.035700Z

It's pretty late here, so I'm going to have to head out. Hopefully, the example helps!

jlmr 2021-02-22T09:23:40.036600Z

I’m sure it will, but will look at it later tonight. Thanks for all the help!

jlmr 2021-02-22T19:30:23.041600Z

@smith.adriane sending this now so it will be there when you’re day starts again (I think we are in very different timezones). 🙂 Does the event-loop in run also execute the view function when no events have been received? I’m asking because I’m trying to understand how the ui can respond to changes to the closed over state that do not originate from events but from the “outside”.

phronmophobic 2021-02-22T19:33:27.043600Z

It depends on the backend. Some of them will check if the view returns something different at least every second regardless. Usually there’s a way to ask for a repaint.