Smart Data Source Registry

The Smart Data Source registry provides an easy way to obtain references to Smart Data Sources from within any component/controller, without the need for the data source to be a direct view child.

 

Obtaining a reference to a Smart Data Source

HTML Markup
<smart-data-source ... smart-object-name="customerDataSource"></smart-data-source>
Component/Controller
import { DataSourceRegistry, DataSourceRegistryEventArgs, SmartDataSource } from '@consultingwerk/smartcomponents-core';
 
private customerDataSource: SmartDataSource;
 
constructor(private datasourceRegistry: DataSourceRegistry) { }
 
ngOnInit() {
	this.datasourceRegistry.dataSourceAdded
				.filter((ev: DataSourceRegitryEventArgs) => !!ev && ev.dataSourceName === 'customerDataSource') //we are only interested in the customer data source
				.subscribe((ev: DataSourceRegistryEventArgs) => {
					this.customerDataSource = ev.dataSource;
				});
}