Currently, there are 2 ways to load data: fetch and subscribe. With a subscription, calling additional fetches or subscriptions will not issue another request. With fetch, we issue a new request anytime fetch is called.
Sometimes it's useful to only fetch if the data is not already loaded. For instance, a function might require some loaded data:
However, the caller may have already fetched $account:
$account.fetch((err) => {
doSomething()
})
The intent of doSomething may just be that it needs the data, but not to refresh. In that case, we need to write additional boilerplate to fetch only if the data isn't already loaded with queries = [].
It would be nice to have something like model.fetchIfMissing(...) that does not issue additional requests if the data exists.
Currently, there are 2 ways to load data:
fetch
andsubscribe
. With a subscription, calling additional fetches or subscriptions will not issue another request. Withfetch
, we issue a new request anytimefetch
is called.Sometimes it's useful to only
fetch
if the data is not already loaded. For instance, a function might require some loaded data:However, the caller may have already fetched
$account
:The intent of
doSomething
may just be that it needs the data, but not to refresh. In that case, we need to write additional boilerplate to fetch only if the data isn't already loaded withqueries = []
.It would be nice to have something like
model.fetchIfMissing(...)
that does not issue additional requests if the data exists.