Fork me on GitHub
Eric Dvorsak08:03:21

is there a way to prevent a refresh when a form is dirty the same way navigating away is currently prevented?


You mean you want to control rendering? Fulcro is meant to be as pure of a V = F(data) (view is a pure function of data) as possible. So, thinking about rendering in the sense of preventing a refresh is definitely the wrong way to think about things. Always think: What do I need to do to my data model to represent the state I want in my view, so that then the view can use that state to accomplish the task at hand. So, the question I would ask you is: why did you change the state if you don’t want to see it change? And, why not write whatever this change is in some non-rendered location instead (if it isn’t meant to be viewed)?

Eric Dvorsak17:03:35

no I'm talking about the warning one gets when navigating away from a dirty form: "You will lose unsaved changes. Are you sure?" I was wondering if there was already a way to have the same thing when the user reloads the page / presses F5. With some research I found that in js it's done with

window.onbeforeunload = function() {
  return "Data will be lost if you leave the page, are you sure?";


oh yes, you just have to do that in low-level js


You could augment the form state machine to do that for you (add/remove the onbeforeunload handler)


and then just use your tweaked one on all your forms

Eric Dvorsak17:03:17

if I do it could I submit it as a PR for RAD? most websites I tested that have forms warning you before navigating away also do it when you refresh


So I’m trying to keep the main form ns free of browser things. I think it would be ok to contribute a form state machine alternative in a new ns that we can pimp out with browser-specific stuff


(the main form ns is meant to be used in any env, not only browsers)


c.f.r.state-machines is the package where I’ve been putting alternative machines

Eric Dvorsak11:03:53

There doesn't seem to be any option "::report/initial-parameters" as mentioned in

::report/initial-parameters       (fn [report-env] {:include-disabled? false})

Pragyan Tripathi15:03:50

Has anyone tried OAuth2 based authentication using Fulcro? I am trying to support login via Google or passwordless with email. Struggling to model the events correctly for the auth state-machine.

Jakub Holý (HolyJak)18:03:37

I ended up implementing this for my app on the backend. I find it more secure to have key communication between my backend and Google auth. I have a ring middleware that checks if you are authenticated and sends you to Google if not.

Pragyan Tripathi02:03:39

Interesting. I was trying to do the similar thing. Generally I would respond with 302 status code and Google Auth URI. But when I am doing this fulcro treats this response as Error.

Pragyan Tripathi00:03:58

Oh incredible. Thanks for pointing it out.

Pragyan Tripathi09:03:48

Hey @U0522TWDA It didn’t work for me. I looked in the networking code of fulcro. When sending, 302 status code fulcro is treating it as 500, also it’s not passing uri parameter in the response. To solve it currently I am sending response with 200 status and redirect-uri. handing that redirect-uri in the frontend. I don’t understand it completely, how it used to work in other applications just on the basis of redirect status code.

Quentin Le Guennec22:03:24

I implemented a google auth via the fulcro-rad auth namespace

Pragyan Tripathi05:03:03

Would you be able to share code snippet to let us know how you did it?