Fork me on GitHub
#untangled
<
2017-05-25
>
claudiu08:05:32

@tony.kay regarding om-css with advanced optimisations.

claudiu08:05:41

In development mode and simple optimisations when i do (pr-str Component) I get a string namespace/Component but with advanced optimisations I get #object[$U "function (){React.Component.apply(this,arguments);this.state=null!= this}"].

claudiu09:05:06

ohh small gotcha. I had :pretty-print false so it removed pr-str.

tony.kay17:05:34

@claudiu so it works now?

claudiu19:05:39

@tony.kay Spoke to soon. most of mixed up the builds and thought it worked.

claudiu19:05:23

As a simple test #?(:cljs (js/console.log (prn-str Root) (pr-str Root))) seems to work on dev, simple but not for advanced compilation

tony.kay19:05:52

I’m not sure why we’re talking about pr-str

tony.kay19:05:47

I thought you had some question about the css support working with advanced

tony.kay19:05:47

ah, from an earlier message. I see. You’re saying that the generated CSS classnames are getting messed with during advanced compilation

tony.kay19:05:50

That is probably a bug with om-css. There is probably some other method of getting the component name that doesn’t work the same when adv compilation is used.

tony.kay20:05:56

In advanced compilation the artifacts are going to be renamed and minified. But I would not expect this to break anything.

claudiu20:05:46

yep strange one. Tried it on a clean chestnut template:

claudiu20:05:17

(defui Component
  Object
  (render [this]
    (dom/div nil "test")))
(js/console.log (prn-str Component) "" (pr-str Component))

claudiu20:05:43

behaves exactly the same 😞

claudiu20:05:09

on clojurescript slack someone suggested that it might be related to this issue: https://dev.clojure.org/jira/browse/CLJS-1249

tony.kay20:05:02

we just need to figure out what the “right way” is to get that string…it is prob not pr-str

claudiu20:05:58

yes 🙂 untangled/om-css is exactly what I was looking for, and the new pull request seems really nice.

tony.kay20:05:11

yeah, I’m excited about the improvements

tony.kay20:05:26

eliminates duplication and simplifies usage

chancerussell20:05:18

Does anyone know of a good tutorial on creating “switcher” components via union queries that isn’t based on Untangled?

tony.kay20:05:43

The Untangled in the Large videos on YouTube walk you though how it is built

tony.kay20:05:49

the HTML5 routing video

tony.kay20:05:57

identical to Om Next

tony.kay20:05:08

other than you have to write the parser that handles the data reads

chancerussell20:05:20

The bit that’s tripping me up is figuring out which parts of the behavior are coming from the untangled-specific initial state stuff

tony.kay20:05:33

@claudiu So, it looks like if we use the React displayName that will survive advanced compile…I’m trying it now

chancerussell20:05:47

Ah, so it’s not expected that the default db->tree would be able to resolve something like this?

tony.kay20:05:48

initial state works for Om Next

tony.kay20:05:01

Untangled’s parser IS db->tree

tony.kay20:05:15

and InitialAppState composes a tree to Root that IS what you’d pass to Om Next

tony.kay20:05:32

I would not dream of using Om Next without InitialAppState

tony.kay20:05:42

eliminates so many headaches with about 10 lines of code

tony.kay20:05:09

it really is just a protocol

tony.kay20:05:17

and a getter to support SSR

chancerussell20:05:33

Yeah. I’m inheriting some non-untangled code and figuring out what’s salvageable

chancerussell20:05:05

And trying to figure out why we didn’t just use untangled 😛

tony.kay20:05:08

oh…I lied

tony.kay20:05:20

InitialAppState for unions has a helper function to add in union initialization

tony.kay20:05:26

which is what you’re tripping over

tony.kay20:05:34

that function would work with stock Om Next too

chancerussell20:05:50

Will take a look. Thanks!

tony.kay20:05:56

I’m biased, but not sure why more ppl aren’t using untangled 😜

tony.kay20:05:07

guess I’m not advertising enough

wilkerlucio20:05:27

tony.kay: my guess would be that people take some time to realize that Om.next by itself is very bare bones, adding Untangled creates more layers than people are used to, maybe we should make a survey, hehe

tony.kay20:05:34

Yeah, I’m thinking the pitch should be something that helps people understand that. I think people see Untangled as something completely different, as opposed to something that makes Om Next easier

chancerussell20:05:58

@tony.kay was merge-alternate-union-elements! the helper in question?

tony.kay20:05:26

it walks the query and uses declared INitialAppState for find the “extras”

tony.kay21:05:23

@claudiu Try om-css version 1.0.2-SNAPSHOT

tony.kay21:05:40

I don’t remember why, but there are CSS tests for augmenting via a defrecord…not sure those will work right in advanced…but not sure why they even exist

tony.kay21:05:08

I think I was thinking you might want to make namespaced CSS without defui (use defrecord instead)

tony.kay21:05:28

I’m going to play with that and see if it still works, but the new version should fix your problem

tony.kay21:05:36

Yeah, I don’t think I can make that one work. So, defrecord support will not work in advanced compilation…use defui instead (you don’t need a render method on a defui). I doubt anyone is doing that, but it is an easy fix.

tony.kay21:05:12

Om-css version 1.0.2 pushed. Fixes advanced compilation