Fork me on GitHub
#reagent
<
2015-10-20
>
gabe14:10:09

Has anyone tried to get Radium working w/ Reagent?

statonjr15:10:48

@eggsyntax: We’re trying to display an “error component” if the callback fails and we’re not quite sure the idiomatic place to do this.

statonjr15:10:05

When the page loads, we call render-component with an accounts-component. In the accounts-component, we call our AJAX function before we return our function component. If the AJAX call succeeds, we update the state of our global atom and the accounts-component renders appropriately. If the AJAX call fails, nothing renders and that area of the page is blank.

statonjr15:10:30

Ideally, we’d return a different component if the AJAX call fails.

statonjr15:10:43

We’re using cljs-ajax to make our AJAX calls.

eggsyntax15:10:26

I haven't tried to do anything quite like that, but what you're saying sounds sensible. Sounds like you need to either use two values (eg accounts-callback-returned and account) or use a special value for a failed callback (eg account could be nil for "hasn't returned yet", false for "failed", and the returned account otherwise). And then do something in your top-level component like (when-not (nil? account) (if account [accounts-component] [failure-component])).

gadfly36115:10:04

@statonjr sounds reasonable to me. A slight alternative is to do the ajax call in whatever page init-like function you have above when the render-component function is called. As an aside render-component is being deprecated in favor of render.

gadfly36115:10:28

@gabe never heard of Radium, but looks great! Definitely curious to try this out :)

gabe15:10:00

@gadfly361: from #C06DT2YSY

statonjr15:10:13

@gadfly361: Thanks for the reminder about the deprecated function.

eggsyntax18:10:42

@statonjr: or alternately, it also seems reasonable to me to have accounts-component itself return different content depending on what the AJAX call returned.

eggsyntax18:10:00

Conceptually, does it feel more like two distinct components or one component that might look a couple of different ways? Seems like a matter of taste to me.

statonjr18:10:46

Two distinct components for sure. Moreover, we may want to have the error-component in a separate namespace so we can reuse the component across contexts.

eggsyntax19:10:16

Ah. That settles that, then simple_smile

coyotespike23:10:01

I want googlebot to love my Reagent webapp. When I enter in a URL with hash, a la Secretary, Google ignores everything after the hash.

coyotespike23:10:42

Do I need to add an exclamation point, to make a hashbang? Or use Accountant, https://github.com/venantius/accountant?

coyotespike23:10:48

Specifically, if I try to add a URL in Google's webmaster tools like , I get "The URL you entered is invalid. Please make sure you have typed it correctly and that it uses the proper syntax and try again."

coyotespike23:10:18

Google used to say we should use https:

coyotespike23:10:52

Does anyone have experience making a Reagent SPA - especially routing - play nicely with search engines?