A view is the entry-point for creating reactive d3 based web applications.
var vm = d3.view({
model: {...},
components: {...},
directives: {...}
});
When a new view is created with the statement above, no binding with the DOM has occurred and the view is in an unmounted state
vm.isMounted // undefined
vm.el // undefined
vm.sel // undefined
To bind a view object into an HTML element
one uses the view.mount method.
The view only affect element
and its children.
This method should be called once only for a given view object:
vm.mount('#app').then(() => {
vm.logWarn('View mounted');
vm.isMounted // true
});
The element can be a W3c selector string,
an HTML element or a d3 selection.
The mount method always return a Promise
resolved once the view is fully mounted.
Views are extendible via plugins. To add plugins into a view
vm.use(myPlugin);
This method can be called several times with as many plugins as one needs, however it can be called only before the view is mounted into an element.
With the exception of the mount and use methods, the view API is available once the view has been mounted to an HTML element, i.e. once the mount method has been called. The API is exactly the same as the component API.