Function ambient_api::prelude::ambient_element::use_memo_with
source · pub fn use_memo_with<T, D>(
hooks: &mut Hooks<'_>,
dependencies: D,
compute: impl FnOnce(&mut World, &D) -> T
) -> T
Expand description
A computation that runs once on spawn, and when dependencies
change. The computation is not re-run
if the dependencies
are the same - that is, the computation is memoized.
Note: using external captures for the create
function will not cause the memoized
value to be recalculated when the captures change.
Prefer to route as much as possible through the dependencies
; these dependencies are available as arguments to compute
.