Local DataSources


#1

I am trying to understand how Local DataSources Work.

The DataSource looks like this:

ui module ModuleName {
    dataSource TargetFields {
        "collection": false,
        "record": true,
        "localData": true
    }
}

I am not certain where to look from here to find more information on the data that is feeding my component. Are there general guidelines for these that can be shared?


#2

If localData is set to true, then you have to populate the data source with the data you need. The component that is listening to this data source will get updated if any change happens in the data source and the appropriate events are triggered (for example, ‘loaded’, ‘modified’ etc).
Note: these events automatically get triggered by the framework when data is fetched from server through ajax calls. But when data is populated in the datasource, it is the responsibility of the developer to make sure these states are handled.


#3

You can also use it as temp local storage and make use of the data binding in your template. In other words, you can update fields in your data source and the same field in your c3ml template will get updated automatically without manually manipulate the DOM.