mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	util: Cleanup CachedValue class.
We use a Symbol for unassigned_value_sentinel and explictly assign the compute_value property instead of using Object.assign. Both of these are needed to type annotate it easily.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							288fe6d388
						
					
				
				
					commit
					899d7bba5a
				
			@@ -159,12 +159,12 @@ export const array_compare = function util_array_compare(a, b) {
 | 
			
		||||
 * You must supply a option to the constructor called compute_value
 | 
			
		||||
 * which should be a function that computes the uncached value.
 | 
			
		||||
 */
 | 
			
		||||
const unassigned_value_sentinel = {};
 | 
			
		||||
const unassigned_value_sentinel = Symbol("unassigned_value_sentinel");
 | 
			
		||||
export class CachedValue {
 | 
			
		||||
    _value = unassigned_value_sentinel;
 | 
			
		||||
 | 
			
		||||
    constructor(opts) {
 | 
			
		||||
        Object.assign(this, opts);
 | 
			
		||||
        this.compute_value = opts.compute_value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    get() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user