Fork me on GitHub
#re-frame
<
2017-11-29
>
shaun-mahood06:11:35

I'm doing a bit of re-frame specific URL routing (think Secretary style but routes are based on re-frame events) and I'm thinking about making it into an effect library - if anyone is interested I'll put some of the details and questions in a thread (the most important being whether my name is too obscure and hopefully some bike shedding around that).

shaun-mahood06:11:32

The main ideas is to make the URL routes just fall out of your effects - when you have an effect that should have a distinct route, you add an interceptor or an effect and it will properly update the URL.

shaun-mahood06:11:04

If you manually browse to a URL (such as your first page visit being to a deep link) it should dispatch the matching event (knowing only what the route can tell you). If you browse using forward, back, or manual entry when the site is already loaded it will dispatch those events as well.

shaun-mahood06:11:43

I haven't found anything quite like this, and I haven't been happy trying to integrate any other routing libraries in the past - it made me feel like my event handlers were 2nd class citizens and I had issues getting manual entry and such working nicely. I also didn't want to have to manually set my routes outside of my event handlers. If you think there's a good solution please let me know!

shaun-mahood06:11:26

On to the most important question - how obscure can my pun be before people will actively avoid my library? My current frontrunner is sash-fillister - it's a type of wooden plane that is used when making wooden window frames using traditional methods, and the most likely replacement for it in a modern shop would be some kind of router. For an informative post on how to use them and to get the totally unnecessary context, see http://eatoncountywoodworker.blogspot.ca/2012/11/how-do-you-use-sash-fillister.html

shaun-mahood06:11:13

I'm planning to make sure it works well before releasing it into the wild, so don't steal my awesome name - but if anyone is interested I can whip up a quick gist or something that you could use to implement what I've got so far. Alternatively, if you think it's a totally dumb idea I'd love to hear why - most of the time there's a really good reason why the libraries I think would be fun don't exist 🙂

shaun-mahood06:11:14

And if you want to get your fill of jargon that has nothing to do with programming, check out the description of them for sale at https://www.garrettwade.com/antique-sash-fillister-plane.html

hkjels09:11:35

I’m curious how this pans out for sure. Haven’t thought of routing as a problem in re-frame, but it could be improved

v3ga10:11:02

Can someone point me in the right direction? I’m attempting to use bidi for routing and I’d like to switch panels when a link is clicked. On line 17 in celestial.cljs should I change my line to url-for to :universe nothing happens. At one brief point I did see an event triggered in the console but I’m running in circles at the moment. https://gist.github.com/jamalburgess/78307af1888ce9b28bb02563fa981aed

danielneal10:11:04

@decim not sure if this is it but this reg-sub looks at the :panel key

danielneal10:11:12

but the property you're setting is :active-panel

v3ga10:11:10

@danieleneal hmm, thanks. That’s certainly one gaff. I updated that but still not getting the result I want. I feel I’m missing calling the subscription all together to cause an action but at the moment i’m lost as far as where I am.

danielneal10:11:46

is dispatch-route getting called?

danielneal10:11:41

The other thing I noticed (I've not used pushy so guessing here) is that your call to pushy/start! might not be happening

danielneal10:11:12

this is in a function but it doesn't look like this function is getting called

danielneal10:11:22

it looks like pushy/start! is a side effecting step that sets up the route handling thing, so will need to be called from wherever you do your initialization and mount the app

v3ga11:11:33

@danieleneal you may be correct there. I haven’t added pushy to core.cljs. That makes sense… Or rather I just threw it in routes.cljs. It really should take place in core.cljs

v3ga11:11:31

@danieleneal sweet, getting there. It didn’t flip to the correct panel yet BUT it did update the db. I should be able to work it out from there. Thanks man.

v3ga11:11:03

@danieleneal thumbs up works 100% now!

v3ga12:11:38

ok odd, it worked once then stopped with no code changing. possibly a caching issue

danielneal12:11:47

where are you calling pushy/start from now?

v3ga12:11:54

in core.cljs init!

v3ga12:11:08

(defn ^:export init! [] (rf/dispatch-sync [:initialize-db]) (load-interceptors!) (mount-components) (pushy/start! (pushy/pushy routes/dispatch-route routes/parse-url)))

v3ga12:11:25

i’d wondered if it should be before mount-components…

manuel12:11:52

@decim yes, I'd put it before mount-components

manuel12:11:58

@decim in my case, it's even before (rf/dispatch-sync [:initialize-db])

v3ga12:11:42

hmm @manuel makes sense. I’m getting there…theres so much going on 😰

manuel12:11:19

@decim if you want a working example, I have this on my GitHub: https://github.com/manuel-uberti/boodle

v3ga12:11:58

so odd…so i moved it..reevaluated and it updated the panel. though now the links still aren’t working. getting closer though. @manuel ahh! thank you! i’ve been looking all over for a bidi/re-frame example!

v3ga12:11:26

this should get me in order

Audrius19:11:43

hi. I Have TextInput element which update ok when typed, bet when text is changed vie subscribe it wraps text, bet number of lines stais the same. how to force it to recalculate it's "(.-height)"

lovuikeng00:11:29

meaning textarea? set scroll to true

reefersleep07:11:27

That depends, do you want your area of text input (note that I didn’t say TextInput nor TextArea!) to grow vertically along with the growing number of lines?

reefersleep07:11:37

I bet it’s much more of a hassle than to use a scrollable textarea, btw. Googled it a little bit, think the following could be converted to reagent with some love: http://www.brianchu.com/blog/2013/11/02/creating-an-auto-growing-text-input/

Audrius10:11:19

thank you a lot guys! 🙂

Audrius19:11:28

It is subscribed to the data field and draws it via ':default-value (or @input-text "")'

Audrius19:11:43

debugging for 5 days 😞