refactor(computed): deprecated computedRunners (#1458)
This commit is contained in:
		
							parent
							
								
									f6da6bf999
								
							
						
					
					
						commit
						5c490f1c45
					
				@ -48,7 +48,6 @@ export function computed<T>(
 | 
				
			|||||||
  const runner = effect(getter, {
 | 
					  const runner = effect(getter, {
 | 
				
			||||||
    lazy: true,
 | 
					    lazy: true,
 | 
				
			||||||
    // mark effect as computed so that it gets priority during trigger
 | 
					    // mark effect as computed so that it gets priority during trigger
 | 
				
			||||||
    computed: true,
 | 
					 | 
				
			||||||
    scheduler: () => {
 | 
					    scheduler: () => {
 | 
				
			||||||
      if (!dirty) {
 | 
					      if (!dirty) {
 | 
				
			||||||
        dirty = true
 | 
					        dirty = true
 | 
				
			||||||
 | 
				
			|||||||
@ -177,16 +177,11 @@ export function trigger(
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const effects = new Set<ReactiveEffect>()
 | 
					  const effects = new Set<ReactiveEffect>()
 | 
				
			||||||
  const computedRunners = new Set<ReactiveEffect>()
 | 
					 | 
				
			||||||
  const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
 | 
					  const add = (effectsToAdd: Set<ReactiveEffect> | undefined) => {
 | 
				
			||||||
    if (effectsToAdd) {
 | 
					    if (effectsToAdd) {
 | 
				
			||||||
      effectsToAdd.forEach(effect => {
 | 
					      effectsToAdd.forEach(effect => {
 | 
				
			||||||
        if (effect !== activeEffect || !shouldTrack) {
 | 
					        if (effect !== activeEffect || !shouldTrack) {
 | 
				
			||||||
          if (effect.options.computed) {
 | 
					          effects.add(effect)
 | 
				
			||||||
            computedRunners.add(effect)
 | 
					 | 
				
			||||||
          } else {
 | 
					 | 
				
			||||||
            effects.add(effect)
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          // the effect mutated its own dependency during its execution.
 | 
					          // the effect mutated its own dependency during its execution.
 | 
				
			||||||
          // this can be caused by operations like foo.value++
 | 
					          // this can be caused by operations like foo.value++
 | 
				
			||||||
@ -245,8 +240,5 @@ export function trigger(
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Important: computed effects must be run first so that computed getters
 | 
					 | 
				
			||||||
  // can be invalidated before any normal effects that depend on them are run.
 | 
					 | 
				
			||||||
  computedRunners.forEach(run)
 | 
					 | 
				
			||||||
  effects.forEach(run)
 | 
					  effects.forEach(run)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user