This allows to access the previously cached value during the recomputation of a cache.
class {
@tracked bidders = [];
@cached
get bidSources() {
const {
// Returns cached value or `undefined` on first computation.
bidSources: previousBidSources = [],
bidders
} = this;
// Generate a BidSource from each bidder, but avoid doing
// it more than once per bidder.
return bidders.map(bidder => {
return previousBidSources.find(prev => prev.bidder === bidder) ||
// expensive as it downloads initial state from server
new BidSource(bidder);
});
}
}
This is not intended to be merged and just for PoC'ing the idea. For this to be merged, the RFC would need to be updated.
Crude implementation of https://github.com/emberjs/rfcs/pull/656#issuecomment-691698733.
This allows to access the previously cached value during the recomputation of a cache.
This is not intended to be merged and just for PoC'ing the idea. For this to be merged, the RFC would need to be updated.