Fork me on GitHub
#re-frame
<
2020-05-16
>
Joel Holmes03:05:14

I’ve tried a couple of times to understand how to use clojurescript and re-frame. Just when I think I get it I run into things I can’t figure out. I have an app that I’m trying to write (in order to learn) and I can’t seem to get toggle to work. https://github.com/Holmes89/clj-read-list. What am I missing? after clicking the button the icon won’t react. I get the put update.

mikethompson03:05:38

@holmes89 you are very unlikely to get a response if you just throw an entire repo at us, with vague talk about some toggle not working. Please create a nice minimal case which doesn't work. Give us a bit of detail. Also, keep an eye out in the javascript console for warning and exceptions, etc. Perhaps review what is happening via re-frame-10x

dpsutton03:05:22

yeah. i actually cloned this but i can't get it to run because its getting a carmine connection error. i need redis locally to run this so i can't help you. sorry

phronmophobic04:05:41

https://github.com/Holmes89/clj-read-list/blob/d8318c4030a305c8f08cd28b02d86aef8511e4a3/src/cljs/reading_list/views.cljs#L41 it looks like the read-book call both fires a toggle-read event and actually toggles the read property of the book. is it possible that it’s being flipped twice?

dpsutton04:05:35

That’s right. Adding a watch and it gets flip flopped

mikethompson04:05:14

I take it back. It does look like you'll get a response :-)

😂 8
dpsutton04:05:01

i actually installed redis and cloned lol

❤️ 4
mikethompson05:05:25

The new re-frame website is available here in a beta state. https://day8.github.io/re-frame-wip/

🎉 44
Michaël Salihi07:05:43

Very nice, I like it!

emak10:05:15

I got a 404 on releases page but it has been fixed now Very nice result 👍 My only suggestion would be to increase a bit the line-height and/or font-size for the contents in .admonition.note

simongray12:05:12

The writing itself is top-notch (seems to be based on the old README.md), but I think hiding the code away 6 pages in is detrimental to the goal of making Re-frame more accessible to newcomers. Please consider putting the code up front. https://github.com/day8/re-frame/issues/582#issuecomment-629639596

👍 4
nprbst00:05:41

Very fine work! Who is the author of the prose? I quite enjoyed the writing style... :-)

Jakob Durstberger13:05:26

I want to use AWS Amplify in my react app. I’d like to check if the user is signed in and redirect them to their dashboard if they are. The library call currentAuthenticatedUser returns a promise so I am not quite sure how to hook that up to my routing. Ideally I don’t want the user to see the homepage and then be redirected after a delay. Could anyone give me some tips on how to do that properly?

pwojnowski14:05:15

I used promesa to handle the promise. When the promise arrived I updated app-db with whatever I wanted, which triggered the flow to the flow further.

Jakob Durstberger14:05:53

So let’s say you want to redirect the user from home -> dashboard if they are logged in. The flow would be * user lands on home -> kick off promise * user is on home <- promise returns after x seconds * redirect user to dashboard Wouldn’t that be annoying for the user?

Jakob Durstberger14:05:23

Sorry for the basic questions I haven’t implemented auth flows on website before 😕

pwojnowski10:05:00

Sorry, I my description was a bit terse. I my case the user lands on login screen. She enters username/password and after hitting enter I do validation after which (assumming it was successful) two things happen: 1. Event handler changes the screen state to :logging-in (I use FSMs as described http://blog.cognitect.com/blog/2017/5/22/restate-your-ui-using-state-machines-to-simplify-user-interface-development and http://blog.cognitect.com/blog/2017/8/14/restate-your-ui-creating-a-user-interface-with-re-frame-and-state-machines ). This activates a sub that changes Login button into a spinner. 2. Event handler returns

:login {:username username
        :password password
        :on-success :login-success
        :on-error :login-error}
Which is handled by reg-fx by calling AWS amplify with given data. When the promise eventually resolves it dispatches :on-success event. Event handler for the event advances FSM state further and dispatches a global event (e.g. ::global-events/user-logged-in that is handled by a top-level handler that advances the screen wherever you want.

👍 4
Jakob Durstberger13:05:07

Thanks, those posts also look interesting

Jag Gunawardana16:05:44

If you’ve ever looked at using kee-frame, then the new FSM (and other functions) work really well. I do something similar for login using urls and kee-frame FSM.

David Pham15:05:21

The resources tabs in the new website is behaving oddly.

mikethompson19:05:08

@neo2551 corrected now (via a PR), many thanks.

David Pham19:05:01

My pleasure. I love the library it is really great to work with.

mikethompson19:05:02

That's generous of you to say, thank you.

David Pham21:05:35

Is it possible to have a collection of all registered events?

David Pham21:05:46

In re-frame?

mikethompson21:05:18

There's no API for it

mikethompson21:05:54

But you can look into the private data within re-frame if you just want a quick hack

mikethompson21:05:57

(keys (:event @re-frame.registrar/kind->id->handler))