Fork me on GitHub
#re-frame
<
2017-04-11
>
danielcompton01:04:52

we just have a template that we copy and do a find/replace on

danielcompton01:04:28

pretty crude, but we haven't seen the value in making it more automated (yet)

kenny02:04:41

Any reason not to access :db from inside a reg-cofx?

danielcompton02:04:04

Seems fine, we have some standard ones that do it already I think. Just be mindful of ordering and interactions with other cofx

eveko19:04:05

does re-frame only recognize 1 app-db or can i have multiple?

souenzzo19:04:29

@eveko there days I asked a "complementary" question: why not pass db as parameter for all functions.

pesterhazy19:04:32

Why would you want to have multiple dbs rather than say different keys in a map?

eveko19:04:40

well , I am at the point that I need more panels... It feels kind of chaotic having keys all over the place, along with different types of collections. Though it could be me clinging of to some old OO perspective ... Also to end with another question I am using bootstrap for css. Is replacing href(in navbar) with on-click re-frame dispatch correct? I apologize if I am asking too many novice questions

owen19:04:24

@eveko the re-frame template project has a good example of routing + views

owen19:04:51

you can still use hrefs if you're using a front-end routing lib like secretary

owen19:04:25

dispatching will work but then you'll lose url handling

eveko19:04:12

I don't need any URL routing, all my data is taken from a java rest api. so I need to dispatch events that make ajax calls, the api has all crud handling. I am indeed using the front-end only template. Though it is going to be fun when I get to present this in class, almost everyone else in my classroom will use angular or jsf for their front end solution.

owen19:04:03

gotcha, I assumed from "I need more panels" + replacing the href you were dealing with routing concerns. I think multiple dbs is against the re-frame mindset, one thing that helps me organize stuff in a large app-db is namespaced keywords

owen19:04:40

and denormalizing data, so instead of a :logged-in-user {:email ...} I would have a ::app/users [] and then ::app.users/logged-in-id 10

owen19:04:44

and filter users with that

eveko20:04:18

I have only seen :: in spec. I have yet to look into that, and it seems like something that i need to study. I already have in my app db though :users [{user1}{user2}] Also, is it a good idea to put the access token inside the app db? or would that be a really bad idea security wise?

owen20:04:05

I wouldn't do it 🙂

owen20:04:40

wait is this for querying from your front end to your backend?

eveko20:04:21

Yeah. The access token is there to inject the user in the request context of the api

owen20:04:18

oh yeah I think thats fine

eveko20:04:04

Am I missing something but if I want to get the sult of a function as the text of html element do I need to enclose it in parens? [:div format-text "some text"] or [:div (format-text "some text")] The first does not change anything in the div, the second makes the page blank

owen20:04:44

the first you arent calling that fn

owen20:04:10

and the idiomatic re-frame way

owen20:04:18

would be to have multiple subs to do this

owen20:04:28

one which provides the text

owen20:04:51

and one which would subscribe to that sub and provide the result of calling format-text on it

owen20:04:11

the first sub :name provides "Bruce", the second sub :greeting prepends that string -> "Hello Bruce"

eveko20:04:28

so its layer 3 I have to look into

eveko20:04:49

But then I am doing a big part of my view build not really idiomaticly

owen20:04:49

non-idiomatic should still work but makes it harder to decomplect (rich hickey (r)) and also I think can lead to things re-rendering when they dont need to

eveko20:04:11

So I suppose I could make subs for members of a map

owen20:04:59

couple of things...

owen20:04:49

clojure
[:ul ;<-- dont forget to surround
  (for [{id: id b :bio} @users]
    ^{:key id} [:li b])] ;<--- dont forget key meta data 

qqq20:04:02

IIRC, re-com was designed for esktop apps. Does re-com team use Electron or NW.js ?

owen20:04:19

and then more what I mean in regards to multiple subscriptions

owen20:04:44

in my example the sub is giving me all the users but I'm only using the :biography key in them

owen20:04:13

however, if the :name of any of the users changes I think this whole ul would re-render as @users itself is a different value

owen20:04:11

but if I were to make a subscription that itself subscribes to users and just returns (map :bio ...) on them then it would not need to re-render

owen20:04:59

this is another example

eveko20:04:54

would something like this work?

owen20:04:37

that's pseudo-clojure but that's the idea, return fully realized data from a subscription so you dont have to do any further manipulation / transformations to it

owen20:04:24

at least that's my understanding from the docs + using this for a while, thompson or compton might read all this later and kick me out of the channel 🙂

eveko20:04:33

I hope note, you have been quite helpful 😅

owen20:04:58

thanks, good luck with the project!

kenny21:04:56

Does :dispatch-n guarantee event order? e.g.

{:dispatch-n (list [:do :all] [:three :of] [:these])}
Would the events always happen in this order [:do :all] [:three :of] [:these]?

mikethompson22:04:41

@qqq we use re-com with Electron @kenny yes, you get that ordering guarantee

qqq23:04:58

@mikethompson : do you guys use lumo or planck by any chaance too? or is it cljs + figwhell ?

mikethompson23:04:51

cljs + figwheel

qqq23:04:49

@mikethompson : so no brepl / cljs-repl ?

qqq23:04:53

just write code, save, and figwheel reload?