Fork me on GitHub
#rum
<
2017-01-05
>
Niki07:01:25

@martinklepsch can you log that request in the issues? Otherwise I'm afraid I can forget about it

martinklepsch10:01:37

Pretty cool I think šŸ˜›

martinklepsch10:01:39

Makes global state a bit more ā€œcontrollableā€ šŸ™‚

niwinz10:01:17

Nice work, one think that I'm pretty surprised is how you use rum for start the system. In my mental mode, I will done the same process but in reverse order. The system will start the ui (not the ui that starts the system)

martinklepsch10:01:31

@niwinz using it with Potok like this btw:

(rum/defc system-wrap < (sys/system (new-system store))
                        {:will-mount (fn [s]
                                       (js/console.log "Injecting system" (::sys/system s))
                                       (ptk/emit! (:store (::sys/system s)) (->System (::sys/system s)))
                                       s)}
  [root-comp]
  (root-comp))

niwinz10:01:39

It makes me feel strange that the UI part of the app is responsible to start the rest of the stuff.

martinklepsch10:01:51

Hm, interesting thought, never considered turning the UI into a component. I think since everything is ā€œexportedā€ via component context it might not be possible but not sure

niwinz10:01:23

In my mental mode, UI is just a part of the system that should be started from the main entry point, and it has its dependencies

niwinz10:01:45

starting UI and on mount start the rest of the system looks very strange on my mental model

niwinz10:01:24

In fact, on my apps I perform many things before the app's UI starts

martinklepsch10:01:32

Well the system is started before the UI is mounted

martinklepsch10:01:51

i.e. Nothing is rendered before the system has started

niwinz10:01:55

I mean that the UI layer and the system is pretty coupled...

niwinz10:01:48

In my approach, I will have functions that starts the system and UI is jut a part of it

niwinz10:01:09

Also, when I run tests, I just run them in nodejs,without headless browser

niwinz10:01:22

so I don't want import anythig related to UI on tests

niwinz10:01:01

so the approach of having UI just a component makes very easy just don't include it when on tests builds

niwinz10:01:20

again, is just share my opinion šŸ˜„

martinklepsch10:01:45

> so the approach of having UI just a component makes very easy just don't include it when on tests builds Or you just start the system and donā€™t have the UI at all

martinklepsch10:01:16

I donā€™t see a big difference in that regard but in theory Iā€™d say you are right. UI depends on other stuff in the system and could be treated as component

niwinz10:01:18

hmm not true, you will need the system-wrap component mounted

niwinz10:01:33

in order to run the same code that initializes the potok stream

martinklepsch10:01:55

@niwinz I can just do (component/start (new-system store))

niwinz10:01:56

on the other hand you will have to repeat the same logic of initialization on tests and ui

niwinz10:01:11

(js/console.log "Injecting system" (::sys/system s))
                                       (ptk/emit! (:store (::sys/system s)) (->System (::sys/system s)))

niwinz10:01:28

the system injection is done on the component...

martinklepsch10:01:32

Ah, you mean that, I see

niwinz10:01:46

I see, it just two lines of code

martinklepsch10:01:51

Yeah, that would have to be done manually. Not a huge deal though Iā€™d say

martinklepsch10:01:18

But as I said, I agree. UI could be a component like others that depends on parts of the system

niwinz10:01:33

it's not huge deal, but I prefer just having to no repeat initialization logic, just because it can change in future and you should not forget to change it on other locations

rauh10:01:50

I actually do the same, start my whole app from the root App component and do a bunch of initialization on will-mount etc

rauh10:01:24

Works pretty well and I remount on every figwheel load so I get a clean state

martinklepsch10:01:00

@rauh clean slate as in all data wiped out? If you repeat initialization logic on updates you probably construct some state outside that logic?

rauh10:01:13

@martinklepsch I guess I didn't mean that. I do a whole remount but my state lives in two places: Datascript + component local state. Both persist the reloads.

rauh10:01:42

So I actually get the same state, or else I have a bug in my SPA and need to remember some local state.

martinklepsch10:01:05

@niwinz toyed briefly with the "UI is a componentā€ idea, definitely seems possible but itā€™s probably where Iā€™ll stop and call it pragatism šŸ˜„

niwinz10:01:36

On my apps I'm not using component nor mount, but I first start router, the potok stream and other stuff, and then the UI. I understand that your approach also works well, it just looks strange to me.

niwinz10:01:16

I don't like much that my entry point is going to be coupled to UI

donmullen17:01:10

@martinklepsch Have you or anyone else you know tried using javelin with rum? Is that even possible? I like hoplon/javelin ā€” but not ideal if wanting to do native mobile - and leverage react-native. How are you storing data for rum apps?

martinklepsch17:01:01

Have never used Javelin so I canā€™t really compare

martinklepsch17:01:21

(there are plenty of alternatives to derivatives)

donmullen17:01:20

šŸ‘:skin-tone-2: