You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My current idea is to hydrate based on different accessors. The API might look like this:
constpostAdapter=createPaginationAdapter({});constpostModel=createModel(initialModel);constgetPostById=postModel.defineAccessor('normal',{// configuration});functionPage({ post }){useHydrate(getPostById(post.id),()=>{postModel.mutate(model=>{postAdapter.upsertOne(model,post)})})}
The useHydrate function will record the provided accessor and execute the function if the current accessor hasn't been recorded yet. When the accessor changes, it removes the previously recorded one and records the new one. In the example above, this ensures that when post changes, we can update the model in real-time.
However, this approach has a drawback. Developers need to place useHydrate at the top level of the component tree to manage accessors centrally and avoid duplicate accessors being passed. Additionally, attention needs to be paid to which models need to be hydrated on which pages to prevent data from being missed.
The text was updated successfully, but these errors were encountered:
Should provide a way to create new state in server to prevent from mutating the global model's state directly in server. It would cause state pollution.
My current idea is to hydrate based on different accessors. The API might look like this:
The
useHydrate
function will record the provided accessor and execute the function if the current accessor hasn't been recorded yet. When the accessor changes, it removes the previously recorded one and records the new one. In the example above, this ensures that whenpost
changes, we can update the model in real-time.However, this approach has a drawback. Developers need to place
useHydrate
at the top level of the component tree to manage accessors centrally and avoid duplicate accessors being passed. Additionally, attention needs to be paid to which models need to be hydrated on which pages to prevent data from being missed.The text was updated successfully, but these errors were encountered: