Fork me on GitHub
#fulcro
<
2019-06-30
>
eoliphant18:06:50

quick question, any suggestions/best practices around using 3rd party js libs for API’s (e.g. a login/auth service like Cognito) I’m currently calling say (.signUp ..) from one mutation, and have the then and catch call other mutations, but not sure this is the best approach

hmaurer19:06:33

@eoliphant so, this isn’t a “best practice” answer because frankly I have no fucking clue (will have to wait for @tony.kay for that one), but it seems to me that it’s preferable to keep I/O out of mutations. You could treat Cognito as a remote, implementing it on the frontend, and passing the auth mutation to it

hmaurer19:06:07

and then using the standard success/error pessismistic mutation callbacks (or just the ok/error handlers in fulcro 3)

hmaurer19:06:26

I haven’t actually done this; that’s a totally untested suggestion

mitchelkuijpers19:06:55

@eoliphant totally agree with @hmaurer try to treat side effecting things as remotes. We did the same with for example localstorage

eoliphant22:06:35

> because frankly I have no fucking clue I can’t stop laughing.. Yeah, doing it in the mutation itself was giving me hives, hence my question. Entirely forgot about custom remotes, will give them a whirl, thanks guys