From ba43d3f28a49c3f6391c139b19b9c94c1d36706a Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Fri, 31 May 2024 14:46:44 +1000 Subject: [PATCH] add more documentation --- docs/computeds.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/computeds.md b/docs/computeds.md index 8dcbb7b94..d38c57ea6 100644 --- a/docs/computeds.md +++ b/docs/computeds.md @@ -151,6 +151,14 @@ class Dimension { +
{🚀} **Tip:** `computed.shallow` for comparing output shallowly + +If the output of a computed value that is a collection with all items identical to the collection from previous computation doesn't need to notify observers, `computed.shallow` can be used. It will do size check and reference equality check for each item, rather than a reference equality check of the collection, before notifying observers. + +In practice, `computed.shalow` is useful only in limited situations. Only use it if changes in the underlying observables can still lead to the same contents in the collection, for example, if we were filtering a list of rectangles by whether they are in a given area, the rectangles included might stay the same even though the area changes. + +
+
{🚀} **Tip:** `computed.struct` for comparing output structurally If the output of a computed value that is structurally equivalent to the previous computation doesn't need to notify observers, `computed.struct` can be used. It will make a structural comparison first, rather than a reference equality check, before notifying observers. For example: