Fork me on GitHub
#hoplon
<
2016-09-01
>
thedavidmeister14:09:01

@onetom i started playing around with boot-static

thedavidmeister14:09:14

ran into a cryptic error though

dm314:09:47

you probably have conflicting versions of Netty on the classpath

flyboarder17:09:26

Has anyone gotten some sort of JS text editor working with hoplon before?

leontalbot17:09:33

@flyboarder Nope. Only markdown, but works like a charm!

flyboarder17:09:28

@leontalbot what are you using for the text-input ? I have been trying to get atom editor working with cljs.

flyboarder17:09:46

but my use is only for markdown anyway

leontalbot17:09:13

I use Google Spreadsheet as input

leontalbot17:09:33

Spreadsheets are interfaces I like for MVPs

flyboarder18:09:33

That is a really good idea!

flyboarder18:09:26

@leontalbot do you use the forms api at all?

leontalbot18:09:54

Google sheet api

leontalbot18:09:32

Hoplon forms are better than Google Forms

leontalbot18:09:52

I am creating forms via a Google spreadsheet

leontalbot18:09:53

the form can even support payments via stripe, something Google Forms can't do...

flyboarder20:09:28

@micha is there a way to invoke an attribute after the element is in the dom?

flyboarder20:09:37

im trying a time delay right now

micha20:09:16

@flyboarder it depends, consider the following:

micha20:09:37

(defelem thing [{:keys [foo bar]} kids]
  ...

micha20:09:59

in that case you need to provide :foo and :bar when you construct the element

micha20:09:29

this is what defelem+ was created for

flyboarder20:09:00

goes and reads about defelem+

flyboarder20:09:15

ok im not sure I follow, the docs just say that attr and kids are a cell

micha20:09:48

with defelem+you can do this:

micha20:09:10

(defelem+ foo [{:keys [color title]} kids]
   (div :css (cell= {:color color})
     (h2 :text title)
     (ul
       (for-tpl [kid kids]
         (li kid)))))
         
...

(defc colors (cycle ["red" "blue"]))
(defc= color (first colors))

(with-interval 1000 (swap! colors next))

(def mything (foo :color color))

(html
  (body
    (myting :title "heythere"
      (div "one")
      (div "two"))))

micha20:09:45

see the difference?

flyboarder20:09:20

kinda, it’s returning an element that you then use normally?

flyboarder20:09:26

so you can get kids from a cell, that makes sense but im not sure i get the difference with the attributes

flyboarder20:09:59

you’ve kinda primed the element with attributes

micha20:09:08

first thing is that the attributes are always cells

micha20:09:53

and the kids argument is also a cell

micha20:09:22

that's why in the defelem+ it uses for-tpl

micha20:09:42

what this means is that you can add children after you've created the custom element

micha20:09:50

or you can add attributes

micha20:09:13

changing an attribute's value causes the corresponding cell in the defelem+ to update

micha20:09:35

the basic idea is that custom elements may have attributes and or children

micha20:09:44

those are both represented as cells

micha20:09:58

if you add or remove children then the kids cell updates

micha20:09:12

if you add or remove or change attributes those cells change

flyboarder20:09:25

so how would I go about adding an attribute later?

flyboarder20:09:07

or is that what happens when I make mything

micha20:09:44

even with defelem you can add attributes later

micha20:09:53

as long as they're not the special ones in the arguments

micha20:09:27

in the defelem+ example above i add an attribute later

micha20:09:34

the :text attribute

flyboarder20:09:48

right thats normal tho

micha20:09:05

oh derp one sec i fix that

micha20:09:27

it should have been the :title attribute

micha20:09:39

i updated the example

micha20:09:16

you should be able to run that, unless i made some dumb typo

flyboarder20:09:39

im not sure I see the benefit with the attributes from a regular defelem

micha20:09:57

with regular defelem you need to provide :title when you construct the element

micha20:09:07

it's just a parameter the constructor takes

micha20:09:20

with defelem+ it's not an argument to the constructor really

flyboarder20:09:54

oh I see so you can pass the argument through to the underlying elem

micha20:09:01

the arglist in defelem+ is actually just a declaration

micha20:09:21

it allocates those cells

micha20:09:34

the cells update when you add attributes or children

micha20:09:00

vs with regular defelem, where the arguments are actual parameters the constructor function takes

flyboarder20:09:37

right gotcha, but im not sure this helps my situation haha

flyboarder21:09:20

attributes are invoked before the element has been attached to the dom right, im looking to invoke it after, that way the element also has a parent, i guess i can attach an event listener inside my attribute for the load event

micha21:09:02

i usually use (with-timeout 0 (some code that needs the parent))

flyboarder21:09:25

in the defmethod ?

micha21:09:25

that only works if you craete the element in an expression that's in the html block though

micha21:09:42

there is also the with-dom macro

micha21:09:54

that polls until the element is in the dom

micha21:09:59

and then it evaluates the body

flyboarder21:09:23

ah that might be what I am looking for!

flyboarder21:09:37

@micha I just noticed but is there no API docs for version 6?

flyboarder21:09:47

oh i see the crossclj docs, hmmm maybe a more read-able set should be generated

micha21:09:58

it's a pain to do docs for cljs i think

micha21:09:14

although now that cljs has var metadata maybe it's time to revisit it

micha21:09:28

i would ideally be able to make the api docs the way i do it with boot

micha21:09:44

like generate markdown for github

micha21:09:52

instead of html websites and stuff

flyboarder21:09:09

yeah i wish codeina had markdown support

micha21:09:35

that's the script that i use to make the boot api docs

micha21:09:33

i like that it's versioned and tagged with the code in github

micha21:09:37

it's simple

micha21:09:45

and you get links to the code that are correct

flyboarder21:09:02

yeah the md is a nice way to go

flyboarder21:09:26

you could also push that to the wiki repo

flyboarder21:09:36

and have it generate over there

micha21:09:54

yeah, but then it wouldn't be versioned with the code

micha21:09:10

i like that you can check out a specific tag in the boot repo

micha21:09:23

and you get the api docs for that exact tag

flyboarder21:09:47

right cuz it’s all bundled