Computed values are values that can be derived from the existing state or other computed values. Conceptually, they are very similar to formulas in spreadsheets. Computed values can't be underestimated, as they help you to make your actual modifiable state as small as possible. Besides, that they are highly optimized, so use them wherever possible.
Computed values are automatically derived from your state if current state value that affects them changes. Computed values can be optimized away in many cases by NGXS as they are assumed to be pure. For example, a computed property won't re-run if none of the data used in the previous computation changed.
By default selectors in NGXS are bound to a state. Sometimes you need the ability to join to un-related states in a high-performance re-usable fashion. A meta selector is a selector allows you to bind N number of selectors together to return a state stream. Let's say we have 2 states; 'zoos' and 'theme parks'. We have a component that needs to show all the zoos and theme parks for a given city. These are two very distinct state classes that are likely not related in any manner. We can use a meta selector to join these two states together like:
When you click the "Increment firstCount" button, you will see that the sum is not recalculated. Why? Everything is very simple, caching occurs when any of the states has not changed and the result is still returned from the cache. In order to help recalculate the value again, if you need it, you will need to manually update the cache:
sequence.updateSequence() - This is necessary if you know that your states use values from third-party services, and not the NGXS states in computed fields.