Queries
Every front end application will need some amount of calculated information derived from the state. As a rule of thumb: if you can calculate it, you should. Keep your state as lean and normalized as is reasonable, and use queries for everything you can.
#
Syntax#
DependenciesThe .with({ ... })
call allows you to specify any dependencies your query has. Queries cannot depend on commands, only state and other queries.
#
Query BodyYour query body is just a function with a special first argument: "little o." This special first argument will contain resolved versions of whatever dependencies you specify. Your query body must be a pure function: no side effects! It should only use the dependencies supplied, and it must always return a value.