Fork me on GitHub

Has anyone tried to get Radium working w/ Reagent?


@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.


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.


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


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


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])).


@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.


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


@gadfly361: from #C06DT2YSY


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


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


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.


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.


Ah. That settles that, then simple_smile


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.


Do I need to add an exclamation point, to make a hashbang? Or use Accountant,


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."


Google used to say we should use https:


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