New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use prerender in the ob init
example app
#320
Comments
Some examples would help as well. Are there any open source obelisk apps/examples out there? |
Going to create a ticket that will make a better error message than the one experienced here. I'm going to reference this issue #241 because examples and documentation using |
@mightybyte FWIW, I'm hoping to deprecate MonadWidget once we sort out how to make the alternatives more ergonomic. |
@ryantrinkle I tend to think that's likely to be the wrong decision, but I'll reserve judgement until I can see the alternative. It seems like this is the age-old constraints-vs-liberties tension. It's really nice to never have to think about what constraint you're using when you're building an app and just use the thing that you know will always give you all the power you might need in the future. I suspect we'll want this as long as the constraints can't be inferred. And even if the constraints can be inferred, we're probably still want something like MonadWidget since writing type signatures is the widespread best practice in Haskell. |
I'm seeing myself deprecating MonadWidget more and more in favor of my own (contained) App/Module/Widget Constraint type synonyms. Aside from making it easier for me to reason about the inner workings of Reflex and Reflex Dom, this practice has also been helpful when abstracting the smaller more reusable reflex components. |
Perhaps a subroute that uses prerender would be a good compromise. That way there's a documented prerender example, but the default route still takes full advantage of server-side rendering and DOM rehydration. |
@ali-abrar Yeah; it could also be just some widget on the page that uses JS; whether or not it's a subroute, it will need some prerender. |
My recommendation on this would be to have an example of using either XHR or websockets in the skeleton, which would then involve putting a prerender just around that bit. The correct impression to give is that prerender is best used around parts of the page which actually render no DOM whatsoever. Of course, we might also want to push the use of prerender into the definitions of those things, at which point, the examples of usage would be harder to come by. |
I like @cgibbard's suggestion. It also lines up quite nicely with something I was just thinking today which is that obelisk should provide a convenience function that opens a websocket using the obelisk-configured route in
And then in
You can work out the details differently of course, but the important parts that weren't obvious to me at first are the need to use I suppose this merits a separate ticket, but I thought I'd see if you're open to the idea before I create the ticket. |
For https, you would need wss instead of ws. |
Ahh yes. All the more reason to solve this problem for people with code! |
Also: we should provide in the FAQ that when someone sees an error like |
The example app generated by
ob init
doesn't use theprerender
function. This makes it not obvious how to go fromDomBuilder
which is needed by_frontend_body
toMonadWidget
which you end up wanting for most of your app. Using something like this would make that more obvious:The text was updated successfully, but these errors were encountered: