Fork me on GitHub
#om
<
2015-10-23
>
tony.kay00:10:22

I'm excited to look it over.

tony.kay00:10:10

I just pushed a dynamic query example doc...it is quite incomplete, but it has a working example to look at. Embeds query fragments with query params. https://github.com/awkay/om/wiki/Om-Next-Dynamic-Queries

dnolen00:10:24

my favorite bit is the pattern that building UIs always start with the data simple_smile

tony.kay00:10:52

@dnolen: I just read the source change. Sweet! This is just what I needed to clean up my example code!

a.espolov00:10:18

Guys (om/set-state! this new-state) it's work?

tony.kay00:10:31

yes, set-state works

tony.kay00:10:42

I'm using it in my example I'm working on right now

a.espolov00:10:22

@tony.kay: example for dynamic query?

tony.kay00:10:31

yeah, that I just posted. It uses it

a.espolov00:10:34

@tony.kay: changed component state should call component render with new state?

tony.kay01:10:31

@a.espolov: Upgrade versions…try alpha4. He fixed a bug in it recently

a.espolov07:10:24

i'm use alpha4

thomasdeutsch08:10:49

Something changed... now, a single-page-app router only needs to do some data fetching/change. When the data is changed -> the UI will display the correct view for it.

thomasdeutsch08:10:30

Of course it was possible before om.next, but now it seems to be very easy/natural to do so. Until this point, you would need a bunch of logic and data-fetching in the parent component if you would make this kind of data-centric routing. In my case it resulted in a lot of data fetching and core.match - now, this code is gone.

thomasdeutsch08:10:00

@dnolen: what is the story about defaults in queries? Is ist possible to use the datomic default function? and what about the maps, how would you add a default for the case that no data is loaded?

dnolen10:10:04

@thomasdeutsch: there isn’t any need for default case beyond syntactic sugar

dnolen10:10:50

you wrote the parser you can sort this out yourself

dnolen10:10:17

you may want to bottom out at Datomic Pull somewhere in your query so the only is that it should work

dnolen10:10:58

@thomasdeutsch: for the case where no data is loaded just supply the data you want to show at startup

dnolen10:10:47

@thomasdeutsch: glad to hear you seeing the benefits of the simplication

dnolen10:10:12

fwiw, I think you’re going to see a lot of code disappear and the result will be something very uniform and very easy to reason about.

gardnervickers13:10:29

Hey all, is there any way to view what changes trigger an update on a specific component?

dnolen13:10:18

@gardnervickers: changes don’t trigger updates

dnolen13:10:26

reads in a transaction do

dnolen13:10:53

the main exceptions at the moment is that we schedule the component that requested a transaction for updates

dnolen13:10:03

set-state! also triggers updates

dnolen13:10:23

set-params! and set-query! as well, but again this only applies to the component that invoked these things.

dnolen13:10:54

so basically the only the thing that changes is the thing that requested a change

dnolen13:10:08

if you want more to change it must be explicitly requested

gardnervickers13:10:11

Ok that’s a lot less involved than I assumed.

dnolen13:10:39

Om Next is nearly in every case explicit over implicit

dnolen13:10:56

the later leads to disaster

dnolen13:10:02

as UI programming in the mainstream has shown

dnolen13:10:54

over the coming months people will start to realize that Om Next doesn’t do anything at all

dnolen13:10:03

it’s just gives your application a structure that’s easy to reason about

bostonaholic13:10:21

if Om Next doesn't do anything, what have you been doing all this time?

dnolen14:10:56

@bostonaholic: haha, I just mean all the code there is just for managing the co-located queries and giving everyone a parsing infrastructure.

dnolen14:10:16

but there’s no magic, you have to write all the parsing code, all the state management, all the re-rendering triggers etc.

bostonaholic14:10:24

no, I get it. I love that mentality

bostonaholic14:10:20

after writing apps in backbone, ember, angular, (and probably more) I agree with that

dnolen14:10:19

right, yes I’m similarly soured on tools that “do smart stuff” for you.

wilkerlucio14:10:21

I'm with you guys, using Om.next really feels something different, I've being writing one app using Falcor recently, and knowing Om.next I'm missing the colocation and parsing management, I'm having to do a lot of it by myself (in a very crude way), that makes me really appreciate your work on Om.next @dnolen simple_smile

dnolen14:10:53

@wilkerlucio: haha, oh yeah. I mean I really, really read through the Falcor docs

dnolen14:10:04

Om Next works the way it does because of that

dnolen14:10:19

there’s a bunch of gross stuff in Falcor that we can automate

dnolen14:10:08

We’re much more like Relay in that regard, but Relay is just a OOP disaster implementation API wise

bbss14:10:14

I am also writing an app using falcor, and redux and find everything said about om next very enlightening

bbss14:10:30

I am actually re-writing http://data.worldbank.org. We can possibly open up the api and document it well so others can have a go at it. I think I will have a look this weekend at if I can integrate om next with falcor.

bbss14:10:47

It is not in production yet but we are aiming to be around december.

wilkerlucio14:10:55

@dnolen: also when I first read your docs about the indexer, that made me feel pretty good, we had those indexing powers for ages with jQuery and they got lost when the MVC'ish frameworks started to pop, and finally the Om.next reconciler, oh my, that's the kind of code that I'm very glad I'll not have to write, so thanks again, following the Om.next development is being a great experience, I can barely wait to start using it on real apps simple_smile

dnolen14:10:01

@wilkerlucio: yeah, still not sure what the indexer means for production - but from a tooling perspective I have some big ideas brewing. Hopefully I have time to take it on, or somebody can carry that torch.

dnolen14:10:32

but basically I think we could have a jaw dropping Chrome DevTools plugin for Om Next.

wilkerlucio14:10:09

yeah, that's good application for it, making a Om.next Devtools plugin in Om.next, that's sounds like a fun project

dnolen14:10:44

like use DevTools to see transaction history

dnolen14:10:00

see a bad query, rewind app state, change source file, Figwheel hotload, done

dnolen14:10:13

programming languages can only do so much

dnolen14:10:26

exposing hooks for powerful tooling is really important

dnolen14:10:43

while I don’t agree with everything Brett Victor says I believe in this part

wilkerlucio14:10:49

I'm familiar with Bret presentations, do you have specific points on what you don't agree with him?

thheller14:10:42

@dnolen I have been experimenting with some devtools stuff .. biggest hurdle is sharing data between browser->devtools

thheller14:10:04

everything must be serializable since we can't just pass JSON arround

thheller14:10:34

it is doable but the "browser" needs IPrintWithWriter for everything and the "devtools" needs a reader

thheller14:10:48

but all doable simple_smile

dnolen14:10:58

@thheller: huh is there a custom serialization format just for DevTools?

dnolen14:10:16

that seems crazy to me, is there security problem with JSON in this case?

thheller14:10:33

no but it can only pass JSON between application frame and devtools

thheller14:10:47

clojure data structures dont go over so well

dnolen14:10:57

this is what Transit is for

thheller14:10:37

yeah but transit needs a writer for every type

thheller14:10:09

it can't just serialize defrecord/deftype/etc

dnolen14:10:14

transmitting random information doesn’t make any sense to me anyhow

dnolen14:10:49

yeah I think that’s also a waste of time

thheller14:10:00

well it is not exactly "random"

dnolen14:10:03

would probably use tagged for that

dnolen14:10:20

passing arbitrary user information is not something to work on.

thheller14:10:47

I was thinking of devtools for om that say ... want to display the results of a Query

thheller14:10:15

that contains user data ... you don't know what might be in it

dnolen14:10:29

right this is the kind of thing I don’t care about

dnolen14:10:40

pass tagged, have some default render for that thing

thheller14:10:04

dammit ... you can't pass tagged is what I'm saying

thheller14:10:20

transit doesn't know the type simple_smile

thheller14:10:39

or is there is way to plug a default writer I haven't found yet?

thheller14:10:41

reading is easy

thheller14:10:39

edn actually kinda works since there is a default for IPrintWithWriter like #object [...]

dnolen14:10:57

you can easily pass tagged for records

dnolen14:10:04

anyways not spending more brain cycles on this

dnolen14:10:07

it’s not a real problem

dnolen14:10:16

and there ways to solve it none which are challenging

thheller14:10:07

agreed .. as I said ... it is all doable

thheller14:10:34

oh wow .. must have missed that

thheller14:10:56

does the transit-clj also have that? I looked at those docs first

thheller14:10:48

anyways, only need the js ... might give this another go then. thanks.

chris-andrews15:10:09

Is anyone using componentWillUnmount in om.next alpha4? It seemed to be working in alpha3, but I’m now getting: `ERROR: Assert failed: Invalid signature for componentWillUnmount got [this], need (= (count sig') (count sig)) at file` Trying to figure out if this is just an issue with my code or a bug

chris-andrews15:10:50

I think from past use of React and double-checking the docs, the signature of [this] for componentDidMount should be correct

dnolen15:10:44

@chris-andrews: probably a bug looking

dnolen15:10:53

@chris-andrews: looks OK over here at first glance but your error doesn’t make sense to me

dnolen15:10:57

unless you made typo

dnolen15:10:05

componentDidMount or componentWillUnmount ?

chris-andrews15:10:46

Yeah, sorry, the second sentence above I typed the wrong thing. It is componentWillUnmount

chris-andrews15:10:12

componentDidMount isn’t having any issues

dnolen15:10:43

@chris-andrews: yep typo fixing and cutting a new release

chris-andrews15:10:57

cool, thanks for checking that

dnolen15:10:38

1.0.0-alpha5 released

chris-andrews15:10:06

@dnolen: I just tested it with my code and the issue is resolved

dnolen15:10:35

@chris-andrews: great thanks for the report

dnolen15:10:48

I really appreciate everybody trying this stuff out

chris-andrews15:10:44

@dnolen: It’s really fun to try out, things are working very well even in the alpha state

dnolen15:10:26

glad to hear it

dnolen15:10:30

more goodies coming simple_smile

tyler16:10:08

is there a way with figwheel + om.next to not have the data reload every time you save? I’m using the code from the end of this tutorial https://github.com/omcljs/om/wiki/Queries-With-Unions and every time I save a change the favorites reset. I’ve tried defonce atom for the state var but that caused an error

dnolen16:10:34

@tyler you need to move your data into an atom, defonce it, use it as :state and pass :normalize true to the reconciler

dnolen16:10:39

when you create the reconciler

tyler16:10:53

@dnolen still not working. It doesn’t throw an error any more when I refresh the page, but it throws an error as soon as a figwheel hot reload is triggered. I made a gist if anyone has a second to take a quick look and make sure I’m not doing something stupid: https://gist.github.com/tvanhens/e90042fed08e8ed23340 if its a bug I can create a ticket with the details

dnolen16:10:41

@tyler it’s not a bug

dnolen16:10:51

don’t have time to explain further sorry

dnolen16:10:15

@tyler whatever you would normally do w/ Figwheel can be done here

dnolen16:10:27

if you’re confused about something specific ask that question only

dnolen16:10:38

not going to look at gists right now

a.espolov16:10:41

Object for defui supported (componentWillUnmount [])?

dnolen16:10:42

@tyler you would also need to defonce the reconciler

dnolen16:10:01

basically think about everything that will be stateful and eliminate that

tyler16:10:22

@dnolen ah that was it thanks!

blissdev17:10:12

In om.old, I’m transacting directly on a cursor, replacing its value with a new value (it’s a map), the update happens successfully but upon rerender the cursor is nil. If I only update a property of the map then it works fine. Should I not transact directly on a cursor in that way?

blissdev17:10:02

Oh just the deref of the cursor is nil, but the cursor is now not a cursor

blissdev18:10:05

Merging with the existing cursor seemed to help.

tony.kay18:10:25

@dnolen: Any chance we can change the defui macro to make the factory, since it is kinda boilerplate noise: (defui Person person ...same as already...)

dnolen18:10:55

I’m very much anti sugar for anything non-essential

dnolen18:10:03

especial in a language where more sugar is just a macro away

tony.kay18:10:06

sure, we can always write our own wrapper

dnolen18:10:37

it also means other people wrappers are dead simple

dnolen18:10:44

and don’t have to handle lots of cases

dnolen18:10:47

syntax is hell

tony.kay18:10:56

"cancer of the semi-colon"

dnolen18:10:36

one thing that I have in mind is that if people want to write a much more powerful layer over the foundation

dnolen18:10:38

it shouldn’t be hard

alexhemard18:10:49

Hello! so... I'm trying to normalize data in om.next that looks something like this:

(def init-data
  {:universe
   {:size js/Infinity
    :beings [{:name "John"}
             {:name "Mary"}]}})

alexhemard18:10:07

I just want to 'normalize' the inner :beings list, but it blows up if I try to normalize without an Ident for :universe.

alexhemard18:10:36

It looks like normalize* expects a vector for the Ident where in this example I'd just want it to be the keyword :universe ... not sure if I'm approaching this all wrong

dnolen18:10:06

@alexhemard: if you’re having trouble with normalization you should show that your defui bits look like

dnolen18:10:11

exactly like the tutorials all show

dnolen18:10:21

just the parts that are needed for normalization

dnolen18:10:25

the rendering parts don’t matter

akiva19:10:31

Are the code samples in the Om.next quickstart possibly outdated? I’m getting a Error: No protocol method IQuery.query defined for type om-tutorial.core/Counter: [object Object] when trying to use this bit of code copy-and-pasted from the page:

(ns om-tutorial.core
  (:require [goog.dom :as gdom]
            [om.next :as om :refer-macros [defui]]
            [om.dom :as dom]))

(def app-state (atom {:count 0}))

(defui Counter
  Object
  (render [this]
    (let [{:keys [count]} (om/props this)]
      (dom/div nil
        (dom/span nil (str "Count: " count))
        (dom/button
          #js {:onClick
               (fn [e]
                 (swap! app-state update-in [:count] inc))}
          "Click me!")))))

(def reconciler
  (om/reconciler {:state app-state}))

(om/add-root! reconciler
  Counter (gdom/getElement "app”))

tony.kay19:10:59

Yeah, I was just looking at that...one of my guys is running through that

tony.kay19:10:10

looks like (query component) is getting called even when there is no IQuery interface

dnolen19:10:22

@akiva: will look at that in a bit

akiva19:10:33

Thank you, sir!

akiva19:10:35

If it helps, the page uses alpha4 as a dependency. I bumped around to alpha3 and 5 but got the same results.

gary19:10:04

@akiva: I'm going through that tutorial now to see if I get the same error

gary19:10:37

@akiva: odd, I've seen that error before when I was on my chromebook, but on Window$ $even the tutorial works fine

akiva19:10:24

Interesting. I’m in a fresh install of OS X 10.11.

gary19:10:35

unless David fixed it just now right before I started doing the tutorial which, to be honest, I wouldn't be surprised if that was the case

gary19:10:30

okay, let me fire up a nix vm and try it there and see if its an environment problem

dnolen19:10:53

checking this issue now

dnolen19:10:05

k I see the problem fixing

gary19:10:52

wow in the Clojure community we're just addicted to the tight feedback loop <crazy parrot removed>

akiva19:10:35

I will pay you $5 to never use that emoji again. I can’t stop staring at it.

dnolen19:10:41

welcome to Slack

dnolen19:10:11

released 1.0.0-alpha6

akiva19:10:34

Exxxcellent. Testing now.

dnolen19:10:06

there’s probably another one coming today if I can wrap up this fancy routing stuff for HTTP caching

akiva19:10:14

Boom. Works. We’ll call alpha6 the Akiva Edition.

gary20:10:23

oh yeah, I've been following the naming thread, need to check and see where its at right now

gary20:10:41

oh, no need to pick a name

tyler20:10:21

Is there any way to force normalization to occur after a mutation? … Or is it better to just insert the data in normalized form in mutations

dnolen20:10:19

@tyler this is why normalize exists as part of the public api

akiva20:10:20

@gary, totally not being serious over here.

tyler20:10:44

@dnolen thanks. Thats the way I’ve been approaching it but didn’t know if that was idiomatic or not

gary20:10:58

@akiva: too late, please donate my 5 dollars you owe me to a charity of your choice

akiva20:10:16

Hahaha done and done.

akiva20:10:52

See, team, look at all the good we’ve caused this afternoon.

dnolen20:10:57

@tyler it does introduce circularity issues if you’re not careful … but I don’t have better ideas at the moment.

thosmos20:10:07

In the om.next quickstart Counter example, an atom is used for app-state, and after each mutation, it reflects current state. In the normalization example, a def is used for init-state and therefore does not reflect current state, which is found in normalized form in the reconciler itself. If I change the init-state to an atom, errors occur with the reads. Is this expected behavior?

dnolen20:10:07

if you pass an atom it must be normalized data

dnolen20:10:18

if it isn’t supply :normalize true to reconciler options

thosmos20:10:03

oh i see, thanks!

dnolen20:10:14

pretty boring commit tbh

gary21:10:45

I never complain about boring commits. My entire afternoon has been lost debugging some interesting commits

joshfrench21:10:21

in the query unions tutorial, where is it stated that an item’s :type should be used to look up the corresponding subquery? is that just handled via ident?

akiva21:10:30

GitHub commits should always be less like Bay and more like Ozu.

akiva21:10:32

[mr. fox whistle and click]

dnolen23:10:53

Covers the HTTP caching bits I wrapped up today, will cover more fun stuff later

tony.kay23:10:47

thanks for keeping the basic idea checkpoints flowing to us. Really appreciate it

dnolen23:10:41

yeah pretty close to beta now

dnolen23:10:08

just need to write a tutorial on remote integration and then will probably switch to beta1

tony.kay23:10:48

very nice. Congratulations

dnolen23:10:01

it’s all coming along nicely, all the “hard” problem turned out to be not so hard, so my confidence in the design is increasing

tony.kay23:10:13

yeah, the more I play with it, the less I feel like I need any kind of fork ...I can't find anything to add simple_smile

dnolen23:10:42

@tony.kay: your AST intuition turned out to be right, I just didn’t know where it was really really needed

tony.kay23:10:41

it wasn't intuition...it was a problem I ran into writing a parser 😉

tony.kay23:10:30

it's just macros on top of cljs.test...but makes writing a spec really nice

tony.kay23:10:45

(and running it with figwheel on multiple browsers dreamy)

dnolen23:10:20

nice to hear that it’s possible to take existing code and make it work in Om Next

tony.kay23:10:35

took abt 45 mins...but our rendering framework already looked a lot like Om

tony.kay23:10:43

so it was pretty trivial