studio/docs/performance.md
When it comes to improving performance, the first place to look is Lona Studio. Any improvements made here should be pretty low-effort, and will likely improve performance for every platform. After that, there are some incremental improvements you can make on each platform.
The best way to improve performance is to render less. Try to use the minimum number of layers possible to create your UI.
Views that can be removed? If a view is used only for layout and only has a single child, it's possible it can be removed. Can you instead put its padding as the margin of its child?Components only re-render when their parameters change. Based on the specifics of your components, you may be able to break them down into smaller parts that don't need to re-render as frequently.
The best way to improve performance is to reduce the number of UIViews used -- this means using fewer layers in Lona Studio. Assuming you've already tried to reduce the number of layers, here are a few (new) optimizations you can consider.
Any time a parameter changes, the update() function runs the component's logic, updating the UI based on its parameters. Setting parameters individually may cause update() to run multiple times. It's best to set them all at once by creating/modifying a Parameters struct and assigning it to the component's parameters member variable.
Lona adds a layer of indirection between function parameters and logic -- this allows the component to always call the latest function passed, without having to re-run the component's logic. Therefore, changing a function parameter will never call update(), since in most cases a function can't affect the UI. There will be a way to opt out of this in edge cases (and call update() on changes), but that doesn't exist yet.
Note that
ParametersisEquatable... but that's a little misleading, since function parameters can't actually be compared for equality (Swift doesn't support this). I'm considering removingEquatable, and instead providing a method for comparing the non-function contents of 2Parametersstructs.
Components are designed to work well in tables and collections, so if they don't, let me know!
For achieving snappy tap/highlight states in collections, see this guide.
Most of the time, code size shouldn't be a huge concern, since these components aren't intended to be modified by hand. However, there can be cases where you'll want to move a file out of the generated directory and modify a portion by hand, or where the code size simply gets out of hand. Here are a couple things you can do:
Coming soon...