Idea
A cache is stored and injected on a per view basis. This allows otherwise expensive styles to be light-weight, and it removes the need for app-wide caches (although such can still be used). As an example, a number style can be modeled as a locale, some bounds, and some precision, which resolve on formatting.
Details
-
Styles should provide a cache.
-
Styles should provide a way of updating it.
-
Views should persist the cache.
-
Views should inject it into the style’s methods.
Extras
An isolated() copy-on-write wrapper can persist its own cache and thereby preserve current behavior, with the added benefit of itself being cacheable and giving the user full control over the lifespan of the cache (it would also make testing easier). The cache provided by this kind of wrapper should be Void.
Comments
I haven’t decided on it. It’s something to think about.
Idea
A cache is stored and injected on a per view basis. This allows otherwise expensive styles to be light-weight, and it removes the need for app-wide caches (although such can still be used). As an example, a number style can be modeled as a locale, some bounds, and some precision, which resolve on formatting.
Details
Styles should provide a cache.
Styles should provide a way of updating it.
Views should persist the cache.
Views should inject it into the style’s methods.
Extras
An
isolated()copy-on-write wrapper can persist its own cache and thereby preserve current behavior, with the added benefit of itself being cacheable and giving the user full control over the lifespan of the cache (it would also make testing easier). The cache provided by this kind of wrapper should beVoid.Comments
I haven’t decided on it. It’s something to think about.