Fork me on GitHub
#re-frame
<
2017-01-07
>
mikethompson00:01:23

@notanon I'd suggest having a read through (see "Notes" on 2nd panel of infographic): https://github.com/Day8/re-frame/blob/develop/docs/SubscriptionInfographic.md And if you want to understand more deeply how it works: https://github.com/Day8/re-frame/blob/develop/docs/SubscriptionFlow.md

mikethompson00:01:09

@chris.hendricks I'm certainly keen for issue 216 (formal API docs) to be progressed. But it is a bit hard because of the method we used to "promote" impl into the API.

chris.hendricks00:01:08

absolutely, I noticed there were some discussions including a macro implementation to get doc strings from the namespaced fns

mikethompson00:01:04

I think there's a couple of issues we have to get sorted ahead of this one which will change the structure of the code.

chris.hendricks00:01:27

you got it, exactly why I asked

chris.hendricks00:01:35

thanks for the reply

mikethompson00:01:34

For example, a resolution to this issue might change everything (in terms of internal code structure): https://github.com/Day8/re-frame/issues/137

mikethompson00:01:42

@chris.hendricks but I appreciate the offer!! Please keep trying to help :-)

chris.hendricks00:01:41

i'll keep an eye out, thanks for a great project

notanon01:01:29

@mikethompson thanks ill check them out

notanon03:01:51

(unrelated to the above)

It is almost like app-db is the temporary place where this imagined perpetual reduce stores its on-going reduction.

Now, in the general case, this perspective breaks down a bit, because of reg-event-fx (has -fx on the end, not -db) which allows:

1. Event handlers to produce effects beyond just application state changes.
2. Event handlers to have coeffects (arguments) in addition to db and v.
Does anyone know what the use cases would be for 2. ? I think the 1. use cases are pretty obvious, effect localStorage or some other non-app-db related effect. But nothing comes to mind for 2.

qqq04:01:03

@notanon: in my understanding coeffects is when you have to do impure functions to get an argument

qqq04:01:18

for example, say you're building a realtime mashup of goog vs fb stock price

qqq04:01:27

the act of pulling the stock price from whatever stream you use would be a 'coeffect'

notanon05:01:56

thanks qqq. that makes sense. seems like the 'next' page in the documentation is going into that. maybe i should read everything before asking questions... it seems like everything is already thoroughly documented (...which is awesome)

qqq05:01:44

@notanon: it's a good question; I was confused on the same issue earlier

qqq05:01:55

@mikethompson spent who knows how many hours helping me out

mikethompson05:01:09

@notanon yeah, i believe the docs cover it. We're talking inputs like: a random number, a GUID, today's datetime, etc.

mikethompson05:01:18

inputs to an event handler

mikethompson05:01:30

Which can't be obtained from app-db or the event itself

mikethompson05:01:55

But also designed with something like DataScrpt in mind

mikethompson05:01:07

The value in app-db itself is considered a coeffect. So, if you had alternative data sources, like a DataScript connection, you caould also inject that as a coeffect, making it available to the event handlers

notanon05:01:05

that makes sense

notanon05:01:06

thanks 🙂

qqq05:01:17

@mikethompson: the default lein template re-frame uses secretary

qqq05:01:38

how is secretary supposed to be used? when I go to a new path, does the app-db get reset, or does the app-db stay the same even as secretary moves around paths?

mikethompson05:01:13

I don;t have a lot of experience with needs in this area. So I'll defer to others on this. todomvc also uses secretary and may be interesting to you, but the choice is not a strong one. There are other libs out there perhaps better. Dunno.

qqq05:01:09

I don't know either; I was mainly curious since the lein template for re-frame includes secretary by default.

qqq05:01:34

@mikethompson: le tme rephrase my question: why have routing at all?

qqq05:01:44

so far, I've just been using an reagent atom, which stores which "page" i'm viewing

qqq05:01:54

why do I want routing in the first place?

qqq05:01:13

It's not secredtary vs bidi / silk; but why routing at all

mikethompson05:01:02

I'm the wrong guy to ask. We don;t need to support routing in our apps.

mikethompson05:01:26

But I'm aware it is a big deal for many. So I'll let them chip in.

mikethompson05:01:02

But it is my understanding that routing does two things for your SPA: 1. It can respond correctly to the back button being pressed 2. Allow for deep linking to certain functionality

notanon05:01:53

3. intercept url changes by the user 4. allow programmatic location changes (insert items into back/forward history)

notanon05:01:41

didn't mean to interrupt mike 🙂

qqq05:01:09

does bidi replace compojure as well?

qqq05:01:16

it's data rather than macros approcah intriuges me

qqq05:01:19

and it seems to do both clj and cljs

notanon05:01:10

looks good

notanon05:01:20

We can match these routes as before :-

user> (match-route my-routes "/index.html")
{:handler :index}
user> (match-route my-routes "/articles/article.html")
{:handler :article}
and in reverse too :-

user> (path-for my-routes :article-index)
"/articles/index.html"

notanon05:01:26

pretty much sums it up

notanon05:01:00

you'll need to copy/paste the extra bits of browser integration (hooking into google closure history api probably)

qqq05:01:42

this is intruiging, if only I have a use for client side routing

notanon05:01:44

when you add +route to the re-frame lein template it uses a place in the app-db to store the "current page" (it's not called that, but thats what it is)

qqq05:01:52

which I still haven't figured out why i need (and re-frame is probably not the right channel to ask)

notanon05:01:54

with secretary

qqq05:01:02

@notanon: whatever chanell we go into , we make it off-topic

notanon05:01:03

you could just unhook the secretary part and plug in bidi

notanon05:01:16

thats just you 🙂

qqq05:01:32

yeah; perhaps I'll replace compojure and my non-existing need for routing with bidi

notanon05:01:30

with re-frame you'd just need to assoc in the current page somewhere in the app-db

notanon05:01:55

and react to it in your view by changing which components are being rendered

notanon05:01:04

just like the +route example in the template

notanon05:01:06

with bidi the value you're reacting to would be something like

{:handler :article}
and you'd update the url to something like
"#/articles/index"

notanon05:01:49

and your view would need to interpret the {:handler :article} as well to decide which components to render

notanon05:01:34

let me know how it works if you try it 🙂

notanon06:01:48

mike mentioned deep linking, bi-directional routing would make it trivial

Now, when we match on an article path, the keyword values are extracted into a map.

user> (match-route my-routes "/articles/123/article.html")
{:handler :article, :route-params {:id "123"}}
user> (match-route my-routes "/articles/999/article.html")
{:handler :article, :route-params {:id "999"}}

notanon06:01:00

seems like a really good fit

gadfly36107:01:03

@qqq i arbitrarily chose secretary for the template (as opposed to bidi, silk, etc.), and as for why client-side routing i agree with @mikethompson and @notanon. I personally use routing for back button and to let my app know which relevant api calls i should make on page refresh.

notanon07:01:54

any problems with secretary so far gadfly?

gadfly36108:01:40

For what i use it for, it works great .. i was curious about trying the other libs out, but never had a strong enough itch

notanon08:01:20

probably need a good use case to justify it i'd imagine

notanon08:01:30

some deeply nested dashboard ui

gadfly36108:01:45

However, i have had problem when trying to remove the # with something like accountant

notanon08:01:01

lots of tabs or some deep ui widget like a sophisticated charting interface

gadfly36108:01:49

My specific problem with that lib was back button and query params ... i now just leave the # in my routes even if its ugly

notanon08:01:12

hehe 'ugly'

notanon08:01:24

we had a contractor mention that for our app

notanon08:01:33

my response was, my end users dont even know wtf a url is

notanon08:01:46

do you think they look at a hash and go 'ugly'

gadfly36108:01:06

I have been using client aide routing for all my apps, some have visualizations and the like, but mostly it is just forms and user accounts etc. Still seems like routing is appropriate tho

notanon08:01:23

(50~ year old underwriters for a giant insurance company)

gadfly36108:01:56

Hahah no you're definitely right, users dont care 😁 .. i was only removing the # for me, but when it didnt work well i added it back haha

notanon08:01:57

if they expect that back button to work... you need it

notanon08:01:10

(routing, not the hash)

notanon08:01:31

our app is very dashboard-y

notanon08:01:01

lots of tabs and info look up (a complete view of a customer's history/policies/etc)

notanon08:01:11

so they use the back button all the time

notanon08:01:34

well.. the ones tech savvy enough to know what the back button is