Fork me on GitHub
#beginners
<
2023-11-25
>
Jonny Johnson16:11:33

Would you guys recommend jumping straight to using MX with CLJD for state management rather than whatever other options there are? I come from developing with Flutter/Dart for 4 years, but am new to clojure. Trying to figure out how to get up to speed with building everything I'm used to in Dart, but with clojure. Things such as: a) state management b) data models 3) event streams 4) provider 5) async/await/futures (been reading slack on this one). Trying to achieve the same level of UI detail in cljd as I had gotten with just dart. Also, are you guys using other libraries like javascript in your dependencies very often?

kennytilton16:11:03

Disclosure: I am the MX author. 🙂 What do you use for state management in the Dart world?

kennytilton16:11:16

ps. I do not use JS libs myself. Is that possible in Dart? Perhaps only for the Web version?

Jonny Johnson16:11:31

Yeah, only the web version

kennytilton16:11:02

Oh, I see you mentioned Provider. MX provides a comprehensive state solution with a lot of transparency. You might check out the https://github.com/kennytilton/flutter-mx/tree/main/examples/example/demo/todoMVC to see what that looks like.

Jonny Johnson16:11:04

I would just love the control of setState((){}) on stateful widgets. I also end up using ValueNotifiers quite a bit

Jonny Johnson16:11:25

I liked what you wrote about the app is the database

kennytilton16:11:31

f/mx handles setState for us. gasp. I recently explored how that is working out and made some tweaks, so I think it is doing a good job at identifying the minimum given any change.

kennytilton16:11:48

"I liked what you wrote about the app is the database..." Thx! An external store was not a bad try, but boilerplate and cognitive disconnect were suboptimal.

Jonny Johnson16:11:52

I read through the counter app example and there didn't seem to be an explicit statement that said setstate, it just appeared to happen automatically...I'm trying to find the example. There was something like fC* (something similar) that pointed to some other code

kennytilton16:11:24

Right. setState is handled automagically.

Jonny Johnson16:11:42

K, I'll give it a go

Jonny Johnson16:11:31

Watched the YT vids you posted with the tts, and was reading through the code to find out where/how the state was getting set and just didn't trust it at first...just a new thing, I suppose, and will try it out

Jonny Johnson16:11:13

Presently got the Method and Event channels to work and trigger native swift code...wanted to ensure I had that kind of interop

kennytilton16:11:23

f/mx sees everything changing. If a formula controls a Flutter property of a widget, it climbs up to the first widget that has a setState and fires that. The only non-Flutter property that triggers setState is the kids, because that maps to child or children in Flutterspeak.

kennytilton16:11:43

I love having Dart veterans on board! Right now I am grappling with Isolate pause/resume. I guess that is another disclaimer: Flutter is new to me. Learning fast of necessity :rolling_on_the_floor_laughing:

kennytilton16:11:42

I will be happy to jump on a call with you for an hour or two to get you rolling.

Jonny Johnson17:11:57

That'd be awesome

Jonny Johnson17:11:09

Free in about an hour?

kennytilton17:11:43

And generally support you until you get the hang of MX. It is different, but several over the years have self-taught, so I think once over the initial hump you will be god to go. One hour will be perfect.

👍 1
Jonny Johnson17:11:25

The isolates were weird to do in Dart to begin with, and they still have yet to get the web version working...there are js workarounds people have adopted atm

kennytilton17:11:07

Yes, I gather they fall back to web workers for compute.

Jonny Johnson17:11:45

I gotta get driving...will chat soon!

kennytilton17:11:01

OK, DM when ready.

kennytilton17:11:26

btw, I extended MX to handle futures/async transparently. I saw the heavy async nature of Flutter and panicked. 🙂

Jonny Johnson19:11:00

Thanks again for being available. Here's the clojure file. It is a simple layout. A cool thing to see, would be the left side bar, appearing|turning off when the page width is < 600. That way there is a little state management in there. Right now, this is just a layout with some onPressed functions that are printing.

kennytilton19:11:29

Got it. I'll first get it running as is, ping you if I get stuck. More soon.

👀 2