2

I noticed in the API that you can stop a Projector, but if it has already rendered some DOM, is there a way to remove it. It appears calling projector.stop() only causes the projector to stop responding.

Kitson
  • 1,650
  • 1
  • 18
  • 36
  • Could you further elaborate on the use case? Why would you want to stop the projector? – Rick Hoving Mar 03 '16 at 08:24
  • Sure. Consider a single page application. Where I would want to manage a "page" of my application by a projector, and add and remove that from my page. I also might have regions of a page where I have a project managing several components, which I would want to dynamically add and remove. – Kitson Mar 03 '16 at 13:02

2 Answers2

2

There is currently no way to instruct the projector to remove what has been rendered. You will have to keep track of which nodes you have appended/merged/etc and remove them yourself.

Johan Gorter
  • 1,253
  • 10
  • 13
  • Johan, thanks for the information. I noticed that VDom's get decorated with DOM node they are related to. I assume I could "clean up" by interrogating those properties on the VDom nodes? – Kitson Mar 03 '16 at 13:04
  • Yes you can. I recommend stopping the projector when you do this. It looks like you want to unregister a 'projection'. This might also be useful for other users. – Johan Gorter Mar 04 '16 at 16:08
2

Since version 2.3, the maquette Projector has a detach function, which can be used to stop a renderMaquetteFunction. The return value contains the DOM Node that can be removed. This seems to be what you were looking for.

Johan Gorter
  • 1,253
  • 10
  • 13