I see Blaze.remove(viewInstance) in the docs, but not anything about removing Template instances directly. Does Blaze.remove(viewInstance) also clean up the Template instance associated with that view?
Template.selfDestruct.onRendered(function() {
  setTimeout(() => Blaze.remove(this.view), 10000)
})
?
             
            
              
              
              
            
            
                
                
              
           
          
            
            
              I answered my own question. It works, kaboom is outputted to the console:
<template name="selfDestruct">
  <div>destroy self</div>
</template>
Template.selfDestruct.onRendered(function() {
  setTimeout(() => Blaze.remove(this.view), 10000)
})
Template.onDestroyed(function() {
  console.log('Kaboom!')
})
It might be nice to have the docs mention that Blaze.remove() also cleans up the template instance.
             
            
              
              
              1 Like