This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-14
Channels
- # announcements (1)
- # beginners (206)
- # calva (2)
- # cider (64)
- # cljs-dev (12)
- # clojars (2)
- # clojure (177)
- # clojure-europe (2)
- # clojure-finland (1)
- # clojure-italy (2)
- # clojure-losangeles (5)
- # clojure-nl (7)
- # clojure-russia (69)
- # clojure-spec (41)
- # clojure-uk (92)
- # clojurescript (60)
- # core-async (16)
- # cursive (48)
- # data-science (6)
- # datomic (73)
- # duct (5)
- # events (2)
- # figwheel-main (5)
- # fulcro (29)
- # hoplon (1)
- # off-topic (52)
- # pathom (11)
- # reagent (4)
- # reitit (5)
- # remote-jobs (1)
- # rum (7)
- # shadow-cljs (58)
- # slack-help (10)
- # spacemacs (3)
- # testing (3)
- # tools-deps (5)
Hi friends, I’ve got 2 questions. 1. If I was going to make use of the aws js cognito sdk, would I write a custom remote for it? I dont think I want the cognito io to happen in a mutation action, which is what led me to the remote. I’ll be doing the same thing today for s3, thus the same question applies for the aws js s3 sdk. 2. I worked through the localstorage abstraction blog post and got that working, but I now see those api’s are deprecated. What is the appropriate mechanism to implement something like the localstorage remote in 2019?
What blog @U0CJ19XAM?
You can always speak with other aws services from your api remote directly, why do you want the UI to talk to them directly?
And I’m trying to determine where the call to cognito should go once I gather the username and pass.
@U6Y72LQ4A when you say “from your api remote directly” what exactly do you mean?
You issue a mutation to your api remote, and the api remote (your backend), will call the various aws apis accordingly
Ok, great so the remote is the right place basically for io side effects to the outside world, like auth, file upload, etc.
Correct
Another suggestion - use the Amplify SDK (which includes Cognito). It includes an HOC for React that wraps your main UI, and handles all the authentication and user signup for you. It also has other components for S3 and other services that are really helpful. I’m using it in my app (which is React Native, but they have components for plain React as well) and it works pretty well. I let it handle all the dirty work, and then it fires events for when a user has signed in, signed up, etc. I handle those and fire a mutation that sets the user info in app state, then let Fulcro take over for everything else. One potential issue with the remote mutation approach and doing auth on the server - what if you want to use Cognito to secure your backend API as well? Maybe not an issue for you, but in my case the backend is a Datomic Ion exposed through Amazon API gateway, which can be configured to restrict access to authenticated members of a Cognito pool - a very nice extra layer of security IMO. Amplify also has an API service that will sign requests based on the Cognito user that’s logged in, so you can get this automatically (just need to write some middleware for the Fulcro networking layer, which I haven’t done yet but looks to be pretty straightforward). But if you authenticate on the backend, you lose that capability. Just something to consider. If you are interested in that approach, I can pull out some code snippets to share (for React Native, but conceptually it should work the same with React web).
I have a multi-step form I’m trying to setup - when I proceed to the next step, with route change, and go back, the values I changed aren’t persisting and going back to initial-state
I’m using secretary, then to change a route I use the (secretary/dispatch! route)
method
could you gist the relevant code? unless I am missing something this should not re-initialise the globla state (unless the whole page reloads). Fulcro doesn’t do anything automatically when the URL changes
Are you using a form
element that is “submitting” to the server? I never use the DOM form
element, since it has that “default” behavior, which of course will reload the whole app.
@U0CKQ19AQ No, right now I’m just changing routes with a “Continue” button. I can share a gist in a bit.
Everything is just a prototype/test of the forms stuff. This is the first I’ve used the newer fulcro forms
So, separate routing from forms. Get the forms working first, then add routing…and I’d suggest using the new dynamic router in incubator when you do
Or at least from what I can tell, its just when I go back and forth between routes that it loses its values and goes back to the initial state
I’m using dirac and can see the global values being updated when I type new values into the fields. Not sure if that helps or not.
Got me. I can’t see how this could be a Fulcro issue. If your state is resetting that only happens if you ask for it to happen (e.g. via a state reset), or reload the page…which secretary could cause if you haven’t set up history event handling correctly. Those are my guesses.
(def the-app (atom nil))
(defn new-untangled-client [& args]
(reset! the-app (apply uc/new-fulcro-client args)))
@U0CKQ19AQ so I’ve confirmed my app-state is indeed staying in tact after changing routes, so it must be something weird with how I implemented this form. It just seems to be looking for the initial-state values over what I’ve added to the query?