Fork me on GitHub
#clojurescript
<
2021-04-09
>
zendevil08:04:34

Hi, I’m implementing Apple Sign In in React Native using this library: https://github.com/invertase/react-native-apple-authentication And there’s a handler for the onPress event of the Apple Sign-In button given like so: https://gist.github.com/zendevil/704508e46017910cfcdfda28768e89ec However, when I convert this to clojurescript like so: https://gist.github.com/zendevil/9b6a6f7a65351ead4cac5759eb051cdd I’m getting the following error: https://gist.github.com/zendevil/f2fa1d09f3946cdbf2bdb04f8d687612 How can I fix this error?

lilactown14:04:39

this looks like the clj->js call is coercing the EMAIL and other special values into invalid things. writing out the JS data structure by hand is probably the smartest thing to do

zendevil08:04:47

I also tried doing this: https://gist.github.com/zendevil/86ed457dea608d3a2c5cde04b40b4b8f But that gives: “RNAppleAuth.AppleAutRequestOptions ‘requestedScopes’ must be an array value if provided.” And removing ‘requestedScopes’ gives a “Promise error”.

lilactown13:04:33

I think you were close with this solution

lilactown13:04:06

you need to add a #js in front of the the [ bracket in

[(.. appleAuth -Scope -Email)
                                                       (.. appleAuth -Scope -FULL_NAME)]

lilactown13:04:45

right now it's sending a CLJS vector, when it expects a js array. a way you create one is via #js []

zendevil17:04:28

@U4YGF4NGM I tried this:

(.performRequest appleAuth
                                   #js {:requestedOperation (.. appleAuth -Operation -LOGIN)
                                        :requestedScopes #js [(.. appleAuth -Scope -Email)
                                                              (.. appleAuth -Scope -FULL_NAME)]})
But that still gives me NSMutableDictionary cannot be converted to ASAutorizationAppleIDRequest

lilactown02:04:11

not without more info

lilactown02:04:27

in the earlier form of this I think that the full error message was relevant

lilactown02:04:51

JSON value '{
    nonceEnabled = 1;
    requestedOperation = 1;
    requestedScopes =     (
        "<null>",
        1
    );
}' of type NSMutableDictionary cannot be converted to ASAuthorizationAppleIDRequest *
you see requestScopes = ( "<null>" which isn't a valid member of the enum on the iOS side

lilactown02:04:04

my best guess is you're still passing something incorrect to it

oliy13:04:59

hello, does anyone know if there a way to detect the compiler version (or closure version) and branch code depending on that? i'm trying to work out how to cope with the https://clojurescript.org/news/2021-04-06-release in a backwards compatible way, namely decide whether to use goog.debug.Logger.Level.SEVERE or goog.Logger.Level.SEVERE

rakyi13:04:30

without knowing the cljs/closure compiler specifics, I’d assume (exists? goog.Logger) could be one way to find out if you are on the newer version

nilern14:04:20

That is probably more robust than reading the version anyway.

oliy15:04:24

ah perfect, thank you i didn't know about exists? . it looks to be exactly what i want

athomasoriginal16:04:27

Take a look in figwheel-core repo. I believe bhauman just solved the problem your looking at. Could be insightful

👍 3
oliy17:04:04

Interesting, he used the clojurescript version (which is available, it turns out). But presumably, although unlikely, the Google closure version can differ from the default one if someone excludes the dep and uses their own version. Here's the code in figwheel-core for anyone interested https://github.com/bhauman/figwheel-core/commit/c51aee22b7d28221df67b7d7848fd2ed80df2528#diff-9714a71e9563e0ef626cd84f6f767ebefe31aa5cead69c25bf4ce8c0f3e634fbR122

sova-soars-the-sora18:04:59

have a rum component that displays 3 strings from a collection of strings. in my on-click for the component,

{:on-click (fn [_] (do
				(reset! names-wedge  (take 3 (shuffle names-quiz-terms)))))}
this will cause an infinite loop where the reset! happens over and over again. can i prevent such loops from happening? I run into this behavior sometimes, could someone help clarify how to prevent this or what's going on?

dpsutton18:04:39

do you have any other resets to names-wedge? this doesn't seem like it should cause an infinite loop.

3
sova-soars-the-sora18:04:17

Thank you that was it ! 😃

sova-soars-the-sora18:04:33

there was a (reset!) in the body of the component ... just hanging out