Fork me on GitHub
#re-frame
<
2016-10-07
>
si1411:10:42

@mattly thanks, I'll check it out! Re: handler: would you mind sketching a minimal example? Sounds interesting, but I'm not sure I'm following properly

plexus12:10:06

when you (subscribe [:foo]) in your views, how do you call the thing you subscribe to?

malcolmsparks12:10:23

> The string is a stark data structure and everywhere it is passed there is much duplication of process. It is a perfect vehicle for hiding information. -- Alan Perlis http://www.cs.yale.edu/homes/perlis-alan/quotes.html

plexus12:10:31

this may seem like a pedantic question, but I feel there's a word missing for a key concept...

plexus12:10:36

hi Malcolm 🙂

mikethompson12:10:29

@plexus not sure of the question. Can you restate?

plexus12:10:43

yeah, trying to order my thoughts so I can elaborate

malcolmsparks12:10:15

instead of "/abc/:id/def" bidi asks you to write ["/abc/" :id "/def"] - nothing to stop you writing some mapping but the reason for the data structure is extensibility. For example, say you wanted the id to be a keyword or uuid (only) to avoid injection attacks perhaps, you can write ["/abc/" [keyword :id] "/def"] or ["/abc/" [uuid :id] "/def"] , and so on, recursively.

plexus12:10:36

reg-sub registers a "subscription handler", under a certain name. When you do subscribe in a view, you create a subscription (IMO you can't speak of a subscription until something has actually been subscribed to). But as long as there is no subscription (from a view), what do you call :blocks? "registered subscription handler" seems the most accurate. So (subscribe [:blocks]) subscribes to... the :blocks subscription handler?

plexus12:10:53

IDK I'm probably being too pedantic, but something like "stream", like you subscribe to the $x stream, instead of you subscribe to the $x registered subscription handler

plexus12:10:13

or maybe the answer is just "subscription", which seems to be how it's used now, so that reg-sub creates a subscription, and subscribe subscribes to that subscription. Just sounds funny to me.

mikethompson12:10:08

Hmm. (subscribe [:blocks]) creates a subscription. A subscription is a reactive query (computation) over app-db. There is a handler which performs the computation and which is registered for the query-id.

mikethompson12:10:31

Not sure I'm helping

plexus12:10:27

yeah kinda ... 🙂

plexus12:10:13

if it's query-id, could you say that reg-sub creates a "query" by that name, and that you subscribe to that query?

mikethompson12:10:52

Hmm. You are making me think here :-)

plexus12:10:10

I guess you could rephrase my question as, what does reg-sub "create"?

mikethompson12:10:43

reg-sub associates a query-id with a handler fn.

mikethompson12:10:36

Later, when a subscribe happens, a signal graph (of some complexity) is instantiated.

plexus12:10:37

yeah, it doesn't "create" so much as it "registers" a thing under a name... I just feel like there's a word missing to point at that as a concept

mikethompson12:10:09

The subscribe is what creates things

plexus12:10:15

but it's fine, I'll just hand wave my way around it 🙂

mikethompson12:10:28

a signal graph

mikethompson12:10:35

involving computations

plexus12:10:04

I know all that, but as a mental model I find that lacking...

plexus12:10:00

"In subs.cljs you declare ... "

plexus12:10:37

you can't say subscriptions, those don't exist until you subscribe. "subscription handlers" would be accurate but wordy. "queries" is conceptually I think closest to what I'm looking for

mikethompson12:10:09

reg-sub is like defn

plexus12:10:24

yes, and defn defines a function

plexus12:10:46

and then you call that function

plexus12:10:55

reg-sub defines a ..., and then you subscribe to that ...

mikethompson12:10:04

And calling that function, may itself cause other functions to be called

plexus12:10:29

reg-sub defines a derived reactive value

plexus12:10:42

reg-sub defines a signal

plexus12:10:49

something like that

plexus12:10:31

I mean it's not super vital, I'll be fine 🙂 but can you see how I'm grappling for a name for this concept?

mikethompson12:10:42

Yeah, i do understand

mikethompson12:10:55

I'm just writing stuff down, waiting for that moment of clarity

plexus12:10:15

cool, thanks for listening 🦆

mikethompson12:10:29

So a signal graph is a runtime concept, like a function call. Only the nature of a signal graph is to hang around, reactively delivering a stream of values over time. At runtime. A signal graph is instantiated via subscribe Note that (subscribe [:blah 1]) will create a different signal graph to (subscribe [:blah 2]) <-- important concept

plexus12:10:12

ok, still with you

plexus12:10:11

the things declared in subs.cljs are used to create nodes in that graph

mikethompson12:10:33

So, reg-sub is about defining a function which can compute a node in a signal graph. In the same way that defn defines the fucnction that gets called.

pesterhazy12:10:31

is it possible to call .focus on a re-com/input-text?

pesterhazy12:10:48

I don't see a way to get a ref to the input DOM node

mikethompson12:10:22

@pesterhazy can you just set the style auto-focus

mikethompson12:10:40

That will initially set focus

mikethompson13:10:05

To a newly instantiated input-field (I seem to remember)

mikethompson13:10:43

I hope I'm remembering correctly

pesterhazy13:10:55

I can indeed

pesterhazy13:10:57

:attr {:auto-focus true}

pesterhazy13:10:52

the wonders of HTML5

mikethompson13:10:59

Mmmm. The HTML5 Drag and drop API

pesterhazy13:10:51

@mikethompson I'm playing around with re-com, it's very nice

pesterhazy13:10:08

is there a way to clear a typeahead control?

mikethompson13:10:42

I'm not sure, it was generously donated. i didn't design, so I haven't had a chance to look into to it much

pesterhazy13:10:15

didn't realize it was so new

pesterhazy13:10:02

I can't seem to change the value by changing the model

pesterhazy13:10:18

that does work for input-text though right?

pesterhazy13:10:27

is there a reason to pass an atom rather than the deref'd as a model?

pesterhazy13:10:34

or is that just a convenience?

mikethompson13:10:50

BTW, the layout side of re-com is the part I'm proudest of.

mikethompson13:10:09

vbox and hbox etc. Given what a nightmare layout normally is

mikethompson13:10:21

But everyone always focuses on the widgets :-)

mikethompson13:10:46

@plexus Over time, I've found it difficult to describe the subscriptions side of things top down - ie. concepts first, then mechanics. I notice that I've always ended up going the other way - mechanics first, leading to concepts. You'll note the README starts off with a discussion of ratoms and reactions (ie mechanism) and then works "upwards" from there towards signal graphs. Now, of course, I can get a bunch of concepts and definitions together, but its always seemed to me that they would just confuse people if they were presented first. But that kinda annoys me. Would love to find a way to go more top down.

pesterhazy13:10:18

@mikethompson I like the layout too but takes a while to get used to it

pesterhazy13:10:43

I'm not crazy about the [comp :k1 :v1 :k2 :v2] structure

mikethompson13:10:53

named parameters?

pesterhazy13:10:04

I think regular reagent style [comp {:k1 :k2} :child1 :child2] is clearer

pesterhazy13:10:15

yes, especially for children

pesterhazy13:10:12

I guess using only named k/v style props is more consistent though

mikethompson13:10:05

We spent a long time agonizing over those decisions. Can't remember all the ins and outs off hand. But it becomes very natural very quickly.

vikeri14:10:30

A question about performance, we are in love with interceptors and use them for persistence, specking app-db and logging in react native. The problem is that since they run without interruption it gets quite laggy. Any tips on the best way I can postpone my side-effecting interceptors and let React Native re-render before it processes them?

si1415:10:26

@vikeri not an expert, but can you just dispatch an event to perform side effects? This way side effects will be deferred

si1416:10:54

uhm, strange, can't find almost nothing interesting in Google about breadcrumbs in CLJS webapps

plexus19:10:48

I'm doing a Lambda Island episode on re-frame (a first of several probably). The example code I'll be using is here https://github.com/lambdaisland/breakout

plexus19:10:28

I'll start recording tomorrow, so if anyone feels like telling me I'm doing it all wrong now's the time 🙂

plexus19:10:51

or you can just play around with the demo https://lambdaisland.github.io/breakout/

shaun-mahood19:10:18

I think you forgot the ball 🙂

plexus19:10:45

it's just the level editor so far, so paddle and ball aren't strictly necessary 😄

shaun-mahood19:10:18

I'll try and look through it a bit and see if anything jumps out at me - not saying I know what I'm doing either though 🙂

plexus19:10:42

I did actually have a working version of the game, but it was a bit hacky. I discovered http://thi.ng/geom too late

plexus19:10:12

I also have some ideas for fun variations on the original, lots of possibilities 🙂

plexus19:10:09

one thing I did wonder, are there guidelines on how to name your events?

plexus19:10:03

mine are a bit of a mixed bag at the moment, some closer to the UI domain, some closer to the game domain, e.g. block-clicked vs create-block

plexus19:10:39

also past tense vs present tense... in event sourcing/cqrs they tend to write them in the past tense

shaun-mahood19:10:19

I prefer a name closer to the domain, at least for what I've been working on latey. I found that if I named it "something-clicked" I ended up wanting it also run in another way (eg from clicking or a keyboard shortcut) and was having to rename things a bunch.

shaun-mahood19:10:39

Refactoring is still very much replace all for some things too, but it's not too bad.

plexus19:10:52

OTOH something you want a click on a thing to do different things depending on the current state of things. Maybe it makes sense to have two "layers", UI events that dispatch to domain events, so multiple UI events can trigger the same domain events, or a single domain event can dispatch to different domain events

shaun-mahood20:10:28

Yeah. I've also found that namespacing my events has helped quite a bit for that type of split

plexus20:10:24

oh right, makes sense

amacdougall21:10:05

@mikethompson: fwiw, I've found the re-com layout containers very handy so far! They remind me of (please take this as a compliment) Adobe Flex, which had quite a good panel-based layout story.

mikethompson21:10:45

@amacdougall I loved Flash/Flex. Loved it. Sooooo very far ahead of the HTML5 game. I was really annoyed when I realised it was going to die. The only good thing to come out of it was being forced across into ClojureScript.

amacdougall22:10:12

Well, that explains the similarities! And yeah, it really let you do a lot... too bad it was based on Flash. Flex was fine, but its runtime was doomed.

mikethompson22:10:58

How good would it be to have Reagent on top of MXML (instead of HTML5)?

amacdougall22:10:51

Seriously. Right now I'm largely protected from the details of HTML (the benefits of being in a larger company), but whenever I have to dip into it, it's... well, a lot better than it was!

amacdougall22:10:23

2001-era HTML/CSS/JS drove me into Java and then back to the front end by way of AS3. Only recently has JS become bearable, at the cost of a Cambrian explosion of tools.