|
|
|
|
|
by anoy8888
1002 days ago
|
|
Some dumb questions: for liveview web / liveview native, is it possible to save rendered code offline and every time it connects to server , it will first check a defined version number ,if the version changes , it will update the code. If the the version is the same or if there is no internet connection, it will use stored code. Perhaps Elixi can be used this way for offline apps while maintaining the dynamic server rendering feature |
|
The tricky part is that Elixir is compiled, and liveview templates are not "files" but functions.
From here you have two choices:
- You create a set of primitives (blocks), and the layout/arrangement of these primitives is configurable via a config map.
- Or you do a hot-code reload: Call an api, check if new code is available, fetch it, compile it (Code.compile_string), load it (:code.load_binary ), swap it for long running processes ( GenServer.code_change callback by example ), and remove old code ( :code.purge )
The first solution is safer. The second solution is a kind of black magic and you would need a way to authenticate de source code before compiling.