untangled

NEW CHANNEL: #fulcro
claudiu 2017-04-20T06:16:54.580017Z

Hi. Has anyone tried Server Side Rendering with , untangled routing ?

claudiu 2017-04-20T06:19:14.597511Z

router-instruction & routing-tree-key seem to be missing in the clj file.

claudiu 2017-04-20T06:20:41.609042Z

for (uc/get-initial-state TopRouter {}) I get No implementation of method: :initial-state of protocol: #'untangled.client.core/InitialAppState

claudiu 2017-04-20T06:42:16.784342Z

Am I doing something wrong or is it not designed for server side rendering ?

gardnervickers 2017-04-20T12:59:51.490706Z

@claudiu I believe there’s a function get-initial-state to deal with calling static methods on the server.

claudiu 2017-04-20T13:02:12.534654Z

@gardnervickers yep. Seem to work for normal components. But for defrouter or components that have defrouter (the macro from https://untangled-web.github.io/untangled/guide.html#!/untangled_devguide.M15_Routing_UI)

gardnervickers 2017-04-20T13:02:55.546902Z

Looks like the router uses get-inital-state, that’s not working for you?

claudiu 2017-04-20T13:04:05.567741Z

worked like a charm for cljs 🙂 but in clojure seems to break

claudiu 2017-04-20T13:05:38.595832Z

re-writing without the defrouter for now (like in the routing getting started video), since that seems to be the problem as far as I can tell.

gardnervickers 2017-04-20T13:20:48.864654Z

Are you sure you’re not calling initial-state anywhere?

claudiu 2017-04-20T13:41:24.282541Z

ohh, you’re right. Don’t exactly what I did wrong but seems like if I remove a more complex component it works.

claudiu 2017-04-20T14:00:28.693413Z

@gardnervickers thank you, all working now. Was calling uc/initial-state Component {} instead of uc/get-initial-state, strangely enough clojurescript app was working just fine.

tony.kay 2017-04-20T15:14:07.434301Z

@claudiu calling the protocol method directly does work in cljs, but it cannot work on the JVM, which is why we provide the additional funciton

tony.kay 2017-04-20T15:14:39.446575Z

Javascript lets you dynamically change a class in a way that works for that. JVM does not.

tony.kay 2017-04-20T15:17:45.520965Z

The syntax on defui (static protocols) is like saying “I want static methods on a class, but I want them to conform to an interface”…the JVM does not have such a thing. Neither does js, but it is dynamic and can fake it

claudiu 2017-04-20T19:11:37.616673Z

@tony.kay cool. Fooled me a bit, since I did not pay close attention there knowing that it worked in cljs 🙂