overview
The $remove method is called whenever a component is removed from a workspace or blog. It lets the component clean up whatever it needs to to full remove itself. Typically this just involves removing any HTML and/or data that the component inserted.
Example Visual Element
when a component has a visual element, it will have typically implemented the $html method, and inserted some HTML into the workspace or blog.
this.$html = function($id){
return '<div id="'+$id(this.config.id)+'"></div></div>'
}
When it is removed, it should remove its HTML. (Note the use of the $id service.)
this.$remove = function($id){
$('#'+$id(this.config.id)).remove();
}
Example Data Component
When a component inserts data into the workspace or blog, it will have typically done so in the $process method, using the $val service.
this.$process = function($val){
$val.set('data', [1,2,3,4,5]);
}
When the component is removed, the $remove method can be used to remove the data. (the choice of whether to remove the data is up to the developer, however, as a general rule, it should be removed.)
this.$remove = function($val){
$val.remove('data');
}