RFC: Liveness
#3870
Replies: 2 comments 1 reply
-
Beta Was this translation helpful? Give feedback.
-
I really like the linked PR and I think it helps justify the approach: we're able to blend react rendering with plain js. I also like how we're utilising our standard approach for hydration to achieve this. If I were new to the codebase and wanted to achieve something similar this helps reinforce how we hydrate as well as defining patterns that could be expanded/replicated. I like how Thinking about future requirements for liveblogs (both known and unknown), the ability to do both react rendering and plain js will be beneficial? I don't think these kinds of questions need a defined answer (and probably not worth spending lots of time on), but just wondering: I like that we've considered alternatives to this approach but I think I'm convinced enough by this to move forward with the idea. Maybe that's just because I'm getting more familiar with |
Beta Was this translation helpful? Give feedback.
-
Please see this PR: #3869
In a previous document we discussed the general strategy for how we make liveblogs live. This PR takes that strategy and proposes an implementation based upon it.
In particular, this PR is proposing an approach where we use a react component
Liveness
to connect and execute the code we want to use to keep the content fresh, but it does not use react to maintain the list of blocks.What features are included?
What is still to be done
Toast
componentHow can we use react but not use react?
A react component is just a function that returns html. But if you tell the function to return
null
then it's just a function. If we insertLiveness
in theLiveLayout
file and wrap it in anIsland
then this code will be executed at page load.With this approach we can choose to use react for some things, like rendering the
Toast
, but use plain javascript for inserting and hydrating the html. It also allows us to use SWR, DCR's react data fetching library, rather than having to introduce or create a second fetching lib to the page.Pros to hybrid
Toast
and keep track of pending updatesCons to hybrid
What alternatives are there to this approach?
Instead of using a react component to trigger this code we could just use a script tag. This is a simple, established pattern for running javascript on the page.
Pros to purity
Cons to purity
Beta Was this translation helpful? Give feedback.
All reactions