Skip to content

Commit

Permalink
[DOC beta] Move API docs for cacheFor (#18254)
Browse files Browse the repository at this point in the history
[DOC beta] Move API docs for cacheFor
  • Loading branch information
rwjblue authored Aug 12, 2019
2 parents adfa3ac + 2a7a55a commit eb5226a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/@ember/-internals/metal/lib/computed_cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ const COMPUTED_PROPERTY_LAST_REVISION = EMBER_METAL_TRACKED_PROPERTIES
? new WeakMap<object, Map<string, number>>()
: undefined;

export function getCacheFor(obj: object): Map<string, any> {
let cache = COMPUTED_PROPERTY_CACHED_VALUES.get(obj);
if (cache === undefined) {
cache = new Map<string, any>();

COMPUTED_PROPERTY_CACHED_VALUES.set(obj, cache);
}
return cache;
}

/**
Returns the cached value for a property, if one exists.
This can be useful for peeking at the value of a computed
Expand All @@ -19,16 +29,6 @@ const COMPUTED_PROPERTY_LAST_REVISION = EMBER_METAL_TRACKED_PROPERTIES
@return {Object} the cached value
@public
*/
export function getCacheFor(obj: object): Map<string, any> {
let cache = COMPUTED_PROPERTY_CACHED_VALUES.get(obj);
if (cache === undefined) {
cache = new Map<string, any>();

COMPUTED_PROPERTY_CACHED_VALUES.set(obj, cache);
}
return cache;
}

export function getCachedValueFor(obj: object, key: string): any {
let cache = COMPUTED_PROPERTY_CACHED_VALUES.get(obj);
if (cache !== undefined) {
Expand Down

0 comments on commit eb5226a

Please sign in to comment.