Fork me on GitHub
#hoplon
<
2016-12-24
>
jumblerg00:12:01

yeah, in theory it should produce a significant improvement.

jumblerg00:12:16

in practice, we're talking about the browser here, so...

thedavidmeister01:12:31

lol, pretty much

thedavidmeister07:12:57

hey, so at some point my live reload from reload boot task broke

thedavidmeister07:12:01

i don’t really remember when

thedavidmeister07:12:11

what are the minimum requirements for that?

thedavidmeister07:12:51

i used to see the little cljs logo popup when i made changes, even that has gone now 😞

candera14:12:53

Reload broke for me when I started using web workers. It appears to inject code into the page that doesn’t work in a web worker context.

candera14:12:08

Do you see errors in the console?

alandipert15:12:48

@candera yeah, reload not compatible with workers

alandipert15:12:57

when i was experimenting with web workers i used a separate cljs.edn

alandipert15:12:10

the problem is the reload wcode depends on window

alandipert15:12:19

which doesn't eexist in the worker context

alandipert15:12:29

(the global object is a Worker, not a Window)

alandipert15:12:57

i think i have my working setup in git somewhere, i'll check

alandipert15:12:03

i had reload going for the non-worker code

candera15:12:14

I am using a separate cljs.edn, because I have to use simple optimizations in my worker for some reason I can’t remember.

candera15:12:27

Hmm. Apparently no I don’t - works now. Wonder if I changed it chasing the reload thing. Awesome! My program just got faster. 🙂

alandipert15:12:57

oh right, using simple optimizations in worker.. also because :none is dependent on window

alandipert15:12:11

which kinda stinks because, no source maps in web worker code 😞

alandipert15:12:20

giving the experience a very 2012 feel

candera15:12:13

I just changed it to advanced and it works, though. But yes, I believe that was the reason I switched.

candera15:12:38

Huh. Reload not working. Weirder, I’m getting an error message about a page other than the one I have loaded.

mynomoto15:12:14

May solve the reload on webworkers problem.

alandipert15:12:31

oh neat! tiny change too

candera16:12:40

But the problem with reload right now does not seem related to web workers. I’ve punted it once again, as hitting refresh is not a big deal for me.

mynomoto16:12:34

Latest problem that people had with reload is related to boot 2.7.0 removal of :target-path as explained at https://github.com/adzerk-oss/boot-reload/issues/106

mynomoto16:12:42

I did a bunch of small things to have reload working and I really like it now. Before I just did what micha says and did a full window reload but I find that flow disturbing now boot-clj

micha16:12:35

@mynomoto what kinds of things did you do to make it work?

mynomoto16:12:26

(ns github-client.core
  (:require
    [devtools.core]
    [github-client.page.core :as page]
    [github-client.reducer :as reducer]
    [github-client.handler.core :as handler]
    [github-client.route :as route]
    [github-client.state :as state]
    [hoplon.core :as h :refer [defelem case-tpl cond-tpl for-tpl if-tpl when-tpl]]
    [hoplon.jquery]
    [javelin.core :as j :refer [cell] :refer-macros [cell= defc defc=]]))

(defonce
  _one-time-side-effects
  (do
    (enable-console-print!)
    (devtools.core/install! [:custom-formatters :hints :async])
    (state/restore-and-watch-db)
    (route/init! state/db)
    (state/start-sync-title)
    (h/do-watch state/title
      (fn [old new]
        (set! (.-title js/document) new)))
    (reducer/start! handler/global state/db reducer/queue)
    (reducer/dispatch reducer/queue [:init])
    ))

(defn init! []
  (reducer/stop! reducer/queue)
  (reducer/start! handler/global state/db reducer/queue)
  (js/jQuery #(.replaceWith (js/jQuery "#app") (page/show {:db state/db :queue reducer/queue}))))

(init!)

mynomoto16:12:01

It's mostly setup and pointing boot-reload to init!

mynomoto16:12:47

onetom was my inspiration, some of his project had a similar setup.

micha16:12:04

what about cells and stuff?

mynomoto16:12:46

Well every once and while I do a full page reload and my machine has 16GB of ram so not a big problem so far.

mynomoto16:12:32

Also there is only one cell that has a datascript db created on a defonce, others are formula ones that will create garbage that will not be collected.

mynomoto16:12:08

But they are scoped on the page/show and there is no risk of stale references I think.

mynomoto16:12:10

I'm trying a global db for a change, I'm happy with it so far. I think I will be able to push a initial version later today.

mynomoto16:12:56

Not that I wasn't happy with local cells before but I'm trying to setup a way to debug stuff where users could send me the db, I could load it and see what happened.

flyboarder16:12:06

@mynomoto: that's very interesting, how do you feel about single atom state?

mynomoto17:12:34

@flyboarder Well trade-offs as always. If your app don't have views that share data I don't think there is a reason to do it and each view would be happy with local state. But if you can have stale things on a view because it was updated on another and you don't want to make requests each time you change views the global state helps.

mynomoto17:12:00

Having a central event handler also helps to have one place to debug order of events and if they happened at all. I'm pretty happy with that.

micha17:12:29

if you have say formula cells that are global or are scoped to some part of your program but accessed in multiple components etc

micha17:12:37

then i think you no longer have single atom type state

micha17:12:04

the thing i don't like about single atom state is that you can't have anonymous things in there

mynomoto17:12:43

How is it no longer a single atom state? Formula cells are derived state no? So the only canonical state there is is the single cell no?

mynomoto17:12:36

I do have anonymous formula cells in this setup, I don't follow the part about not having anonymous things.

micha17:12:51

the formula cells don't need to be pure functions

micha17:12:01

or they can depend on local cells too

micha17:12:12

they can update even when the atom does not

micha17:12:36

it's just the idea of having essentially a message bus in the atom that i don't like

mynomoto17:12:39

Oh, I see. I don't have any other non formula cell in the app.

micha17:12:33

you don't have components that maintain their own state with input cells?

mynomoto17:12:07

@micha not in this experiment. Every thing is on the global state.

micha17:12:53

interesting

mynomoto17:12:31

I'm still not sure about performance on low end devices but so far it works in my machine which doesn't mean much.

micha17:12:08

yeah i don't think performance is affected either way

micha17:12:29

at least intuitively i would think the two approaches would be comparable

micha17:12:37

since the actual work being done is about the same

micha17:12:47

like your formula cells are pruning updates still

micha17:12:04

and your transactor function is like a javelin dosync

micha17:12:39

i'm interested to see how it affects the composability of your components

micha17:12:24

my thinking is that local state, anonymous cells, etc facilitate composition by encapsulating state at different levels of abstraction

micha17:12:46

maybe that's wrong though

micha17:12:00

with the big atom you have only one level of abstraction

micha17:12:31

but i suppose you could make some device that uses gensyms to simulate lexical scope

mynomoto17:12:55

Yeah, conventions are really important with the big atom.

micha17:12:15

it makes libraries of components somewhat brittle i would think

micha17:12:24

or at least overly verbose to use

mynomoto17:12:56

I'm currently using namespaced keywords for identifying local state.

micha17:12:00

right but when you haev components that interact with each other

micha17:12:10

they will need to know about each other's keys

micha17:12:22

this is like programming to concrete types vs interfaces

mynomoto18:12:21

Well the other way they would need to share cells right? Something is needed anyway.

flyboarder18:12:57

@micha im trying to get my boot-nodejs server task to restart whenever the server file changes but not have it interfere with the rest of the pipeline

flyboarder18:12:38

I'm currently trying to figure out when to restart the server, how do I track the one file?

micha19:12:52

you're using the fileset-diff stuff right?

flyboarder19:12:22

I was modeling it after how the hoplon task tracks files