function destroy (component, removeNode=true) {
  if (syncUpdatesInProgressCounter > 0 || syncDestructionsInProgressCounter > 0) {
    destroySync(component, removeNode)
    return Promise.resolve()
  }

  let scheduler = getScheduler()
  scheduler.updateDocument(function () {
    destroySync(component, removeNode)
  })
  return scheduler.getNextUpdatePromise()
}
function destroy (component, removeNode=true) {
  if (syncUpdatesInProgressCounter > 0 || syncDestructionsInProgressCounter > 0) {
    destroySync(component, removeNode)
    return Promise.resolve()
  }

  let scheduler = getScheduler()
  scheduler.updateDocument(function () {
    destroySync(component, removeNode)
  })
  return scheduler.getNextUpdatePromise()
}
function destroy ( component , removeNode = true ) { if ( syncUpdatesInProgressCounter > 0 || syncDestructionsInProgressCounter > 0 ) { destroySync ( component , removeNode ) return Promise . resolve ( ) } let scheduler = getScheduler ( ) scheduler . updateDocument ( function ( ) { destroySync ( component , removeNode ) } ) return scheduler . getNextUpdatePromise ( ) }
Removes the component's associated element and calls `destroy` on any child components. Normally, this function is asynchronous and will perform the destruction on the next animation frame. If called as the result of another update or destruction, it calls `destroy` on child components synchronously. If called as the result of destroying a component higher in the DOM, the element is not removed to avoid redundant DOM manipulation. Returns a promise that resolves when the destruction is completed.
Removes the component s associated element and calls destroy on any child components . Normally this function is asynchronous and will perform the destruction on the next animation frame . If called as the result of another update or destruction it calls destroy on child components synchronously . If called as the result of destroying a component higher in the DOM the element is not removed to avoid redundant DOM manipulation . Returns a promise that resolves when the destruction is completed .