It would be nice to pretty easily pre-fetch data from a server, or pre-compute data even if it's on a client. For example, if you're loading a TODO list, you could return an empty todo list in your wasm app, and then grab the TODOs from the server via an RPC call. Maybe a rough idea how it could work?
// Factor library code
type Prerenderer interface {
func Prerender() (interface{}, error)
}
// Component code that a user writes
func (comp *MyComponent) Prerender() (interface{}, error) {
todos, err := rpcClient.GetTODOs()
if err != nil {
return nil, err
}
return todos, nil
}
factor build and similar commands can generate code that calls Prerender on components that implement Prerenderer before they are rendered and replace the contents of the component with the data returned.
It would be nice to pretty easily pre-fetch data from a server, or pre-compute data even if it's on a client. For example, if you're loading a TODO list, you could return an empty todo list in your wasm app, and then grab the TODOs from the server via an RPC call. Maybe a rough idea how it could work?
factor build
and similar commands can generate code that callsPrerender
on components that implementPrerenderer
before they are rendered and replace the contents of the component with the data returned.