Fork me on GitHub
#re-frame
<
2018-05-13
>
jco09:05:39

I'm making a small Sokoban game in re-frame, and I want some way of "simulating" cursor key movement on a touchscreen. I.e. I want an event to trigger when the player presses the left part of the screen etc... Do I need to create some big overlapping divs, or are there other ways?

aleksandr14:05:47

@eoliphant Can you show a small example of the "indexed entity approrach" pls?

eoliphant14:05:31

{:products/by-id {1 {:id 1 :name "foo"}
                              2 {:id 2 :name "bar"}}

eoliphant14:05:08

sorry hit return too soon lol

eoliphant14:05:33

basically you normalize colletions

eoliphant14:05:47

that then allows you to create direct refs

eoliphant14:05:56

[:products/by-id 1]

eoliphant14:05:40

I have some code that jams stuff that I pull down from the server into this format

aleksandr14:05:52

Yes. This approach updates app-db elements easily

eoliphant14:05:04

it’s also nice because you only need a single instance of a ‘product’

eoliphant14:05:27

if you need it anywhere else you just use a reference

eoliphant14:05:00

{:cart [[:products/by-id 1] [:products/by-id 2]}

eoliphant14:05:56

I’d built this dynamic form tool with re-frame. And I’d modeled everything ‘naturally’ , and it was a nightmare lol. really deeply nested stuff. I then learned specter to help with it. But then I read about this approach, then just rewrote it like this.. But at least I learned specter lol

aleksandr14:05:04

I face deeply nested stuff too

eoliphant14:05:30

yeah in many cases this can clean it right up

aleksandr14:05:39

But I didn`t learn specter yet))

eoliphant14:05:46

you basically end up with a simple navigable graph database

eoliphant14:05:15

yeah if what you’re doing needs the nesting, specter is worth the time to learn

eoliphant14:05:10

especially when you’re updating/inserting/etc you can do a lot of stuff with one-liners

eoliphant14:05:28

and it preserves the ‘type’ of what you’re working on

aleksandr14:05:58

Yes, I do it

eoliphant14:05:06

if you say update the values in a map, there’s no need to do the (into {} …)

shakdwipeea18:05:45

Hi guys, I tried to run re-frame on clojure and it works for most parts but I am running into an issue where the event handlers are not being called after a dispatch. What should I look into ?

eoliphant19:05:38

do you have re-frame-10x or re-frisk installed?

eoliphant19:05:46

that’s the easiest way to check

eoliphant19:05:13

wil show you the events that have been dispatched, subscriptions that are active etc