Fork me on GitHub
#hoplon
<
2016-08-26
>
laforge4916:08:03

@micha Instead of using a case-tpl, I need to use a multi-method to dispatch the element. How to do this? I tried if-tpl, but to no avail. Perhaps defelem will work?

laforge4916:08:47

defelem does not seem to help at all in this case. 😞

laforge4916:08:23

Perhaps I need to write my own -tpl macro?

micha16:08:08

@laforge49 you can use multimethods, why not?

micha16:08:10

(defmulti foop (fn [x y z] ...))

(if-tpl (cell= (< x 100))
  (foop ...)
  (something-else ...))

laforge4916:08:56

I tried that in an if-tpl. First, I needed to dereference the cell when calling foop from the body of the if-tpl. Second, the subtree didn't change when x changed.

micha16:08:28

that's how it's supposed to work though

micha16:08:35

it's static allocation, just lazy

laforge4916:08:45

Hmm. I assumed I needed to dereference because the cell itself was passed. Which generally means it didn't work.

micha16:08:48

foop only runs once

laforge4916:08:58

yes, that's the problem.

micha16:08:00

for the lifetime of the application

micha16:08:07

it's how it's supposed to be

micha16:08:15

foop should be reacting to the changes

laforge4916:08:23

I need to be able to force foot to react to changes.

micha16:08:43

right that's why elements can have attributes whose values are cells

micha16:08:56

you create the element once, and it manages its own state

laforge4916:08:29

so I need to toggle the different subtrees.

laforge4916:08:18

Many thanks!

laforge4918:08:14

Not getting very far, @micha

laforge4918:08:49

everything works fine now, so long as I call the dev's as children.

laforge4918:08:22

I even have the children in a vector in a cell, so this works:

laforge4918:08:23

(@dispatch 0) (@dispatch 1)

laforge4918:08:05

What I can't get working is any kind of loop, even for-tpl, for calling all the subdom trees

laforge4918:08:48

Only hard-coding references to the children seems to work.

micha18:08:04

the thing to keep in mind is that allocation only occurs once

laforge4918:08:22

yes, so I allocate all and then toggle

laforge4918:08:18

but I only seem to be able to allocate by including each child explicitly. Or can I use apply???

laforge4918:08:34

(each child div includes a toggle of its own.)

laforge4918:08:13

I'm composing a vector of children but do not know how to use that vector.

micha18:08:57

each node, once created, is not destroyed when the cells change

laforge4918:08:59

Or rather, @micha, I should say that I'm composing a vector of all possible children.

laforge4919:08:15

but what can I do with the vector?

laforge4919:08:33

Perhaps I need a macro to unwind it?

micha19:08:43

here is an example

micha19:08:42

here is how it's actually used:

laforge4919:08:13

:bindings is the obsolete form, eh?

micha19:08:26

it's still supported, but yeah

laforge4919:08:55

this does not work for me:

laforge4919:08:56

(div (for-tpl [d dispatch] d)))

laforge4919:08:26

Oh! it does!

laforge4919:08:37

never mind. I fixed something else in the meantime.

micha19:08:23

the example i linked shows one way of handling trees

laforge4919:08:33

Its another hot day and Rupali was cooking for hours in our 1 bdrm apt.

micha19:08:56

like most allocators, the *-tpl things use sequential array of memory

micha19:08:09

so making trees is not always strightforward

laforge4919:08:09

so my vector dispatch-all is now working

laforge4919:08:10

The idea is that which tabs are available to a user depends on the individual account.

laforge4919:08:00

In this example, Freddy Krugar has access to the shared contacts, but Kriss Kringle does not.

laforge4921:08:38

@micha I seem to be haunted by an initialization error. I get this:

laforge4921:08:27

It occurs when I use the for-tpl now rather than hard-code the children.

laforge4921:08:06

My code was working, then I moved a few things to another namespace. Not sure what I did wrong, can't make sense of the trace.

laforge4921:08:46

And modifying the code gives me no clue.

laforge4921:08:39

This is the code giving me a problem: (div (for-tpl [d login/dispatch] d))

laforge4921:08:52

and it worked when dispatch was in the same namespace.

flyboarder21:08:07

@laforge49: does it work if you create a local let binding for 'login/dispatch' as a different var?

laforge4921:08:14

Oh great. I had checked in the last working version. Undid all the changes to get back there and the problem persists.

laforge4921:08:00

It is now in the same namespace and does not work. I'm back now to what used to work, as best I can determine using git.

flyboarder21:08:41

I have a new method of making my IDE do a commit to my local repo on every file save for this reason

flyboarder21:08:31

And then I just rebase to remove the unneeded commits

laforge4921:08:35

This works: (div (@dispatch 0) (@dispatch 1)) #_(div (for-tpl [d dispatch] d)))

flyboarder21:08:04

@laforge49: do you have a cell of cells?

laforge4921:08:41

Here is how I construct dispatch:

laforge4921:08:07

So dispatch contains all possible child elements. which self toggle.

laforge4923:08:10

Solved by @flyboarder - just pass a vector to an element. It flattens it.