DataSourceManager

Class

The DataSourceManager is used to manage data source, including create/get/destroy data source instance. Please always use DataSourceManager.getInstance() to use this class. For example, to get a data source, you can use DataSourceManager.getInstance().getDataSource(dsId) . For widget developer, DataSourceManager.getInstance() return the same instance for both widget and widget's settings.

To use data source, the recommended way is to use DataSourceComponent , which is more handy.

Methods

MethodReturnsNotes
Promise<DataSource[]>

Return the successfully created data sources only. For the failed created data sources, return null.

Promise<void>

Create all data sources by time. By default, the method will start to create 30 data sources (do not wait for them to be created), then wait for 1000 ms, and then start to create the next 30 data sources. When creating one data source, the method won't create any of its child data sources.

createDataSource(mainDataSourceId, dataViewId?, localId?, createError?)
Promise<DataSource>

This method is used to create data source instance. Main data source, data view or local data source are created as data source instance.

createDataSourceByUseDataSource(useDs, localId?, batchInstanceStatusChange?)
Promise<DataSource>

Create data source according to the used data source info, and will create a local data source if localId is passed in.

Return the data source instance by ID. If the data source is not created, it will return undefined.

Return the instance of DataSourceManager. If the instance is not created, it will create a new one. If the instance is created, it will return the existing one. The instance is shared by the app and the builder.

createAllDataSources

Class Method
createAllDataSources(): Promise<DataSource[]>

Return the successfully created data sources only. For the failed created data sources, return null.

Returns 
Promise<DataSource[]>

createAllDataSourcesByTime

Class Method
createAllDataSourcesByTime(numnumber, msnumber): Promise<void>

Create all data sources by time. By default, the method will start to create 30 data sources (do not wait for them to be created), then wait for 1000 ms, and then start to create the next 30 data sources. When creating one data source, the method won't create any of its child data sources.

When creating data sources by time, the method will batch to dispatch the data source instance status changes ( NotCreated and Created ) by passing batchInstanceStatusChange to true. It is to reduce the number of dispatches and improve the performance. If widgets create data sources by the data source component (via createDataSourceByUseDataSource method), the batchInstanceStatusChange will be set as false by default. That is to say, won't batch to dispatch the data source instance status changes if the data sources are used by widgets.

Parameters
ParameterTypeDefault
num
number
30
ms
number
1000
Returns 
Promise<void>

createDataSource

Class Method
createDataSource(mainDataSourceIdstring, dataViewId?string, localId?string, createError?boolean): Promise<DataSource>

This method is used to create data source instance. Main data source, data view or local data source are created as data source instance.

The parameter can be a data source id, data source config JSON or DataSourceConstructorOptions .

If pass in dataViewId , this method will create a data view. If pass in dataViewId and localId , this method will create a local data view. If pass in localId , this method will create a local data source. If pass in createError , this method will dispatch the data source instanceStatus as CreateError .

To create a main data source instance, this method do the followings:

  • Create the data source object.
  • Call the object's ready() method.
  • Call the object's fetchSchema() method.

When start to create the data source instance, this method will set the data source instanceStatus as NotCreated at first. The instanceStatus will be set as Created when the creation process is done. The instanceStatus will be set as CreateError if an error occurs.

Parameters
ParameterType
mainDataSourceId
string
dataViewId
string
localId
string
createError
boolean
Returns 
Promise<DataSource>createDataSource(dsJsonIMDataSourceJson, dataViewId?string, localId?string, createError?boolean): Promise<DataSource>

This method is used to create data source instance. Main data source, data view or local data source are created as data source instance.

The parameter can be a data source id, data source config JSON or DataSourceConstructorOptions .

If pass in dataViewId , this method will create a data view. If pass in dataViewId and localId , this method will create a local data view. If pass in localId , this method will create a local data source. If pass in createError , this method will dispatch the data source instanceStatus as CreateError .

To create a main data source instance, this method do the followings:

  • Create the data source object.
  • Call the object's ready() method.
  • Call the object's fetchSchema() method.

When start to create the data source instance, this method will set the data source instanceStatus as NotCreated at first. The instanceStatus will be set as Created when the creation process is done. The instanceStatus will be set as CreateError if an error occurs.

Parameters
ParameterType
dsJson
IMDataSourceJson
dataViewId
string
localId
string
createError
boolean
Returns 
Promise<DataSource>createDataSource(optionsDataSourceConstructorOptions): Promise<DataSource>

This method is used to create data source instance. Main data source, data view or local data source are created as data source instance.

The parameter can be a data source id, data source config JSON or DataSourceConstructorOptions .

If pass in dataViewId , this method will create a data view. If pass in dataViewId and localId , this method will create a local data view. If pass in localId , this method will create a local data source. If pass in createError , this method will dispatch the data source instanceStatus as CreateError .

To create a main data source instance, this method do the followings:

  • Create the data source object.
  • Call the object's ready() method.
  • Call the object's fetchSchema() method.

When start to create the data source instance, this method will set the data source instanceStatus as NotCreated at first. The instanceStatus will be set as Created when the creation process is done. The instanceStatus will be set as CreateError if an error occurs.

Parameters
ParameterType
options
DataSourceConstructorOptions
Returns 
Promise<DataSource>

createDataSourceByUseDataSource

Class Method
createDataSourceByUseDataSource(useDsUseDataSource | IMUseDataSource, localId?string, batchInstanceStatusChange?boolean): Promise<DataSource>

Create data source according to the used data source info, and will create a local data source if localId is passed in.

Parameters
ParameterType
useDs
UseDataSource | IMUseDataSource
localId
string
batchInstanceStatusChange
boolean
Returns 
Promise<DataSource>

getDataSource

Class Method
getDataSource(dsIdstring): DataSource

Return the data source instance by ID. If the data source is not created, it will return undefined.

Parameters
ParameterType
dsId
string
Returns 
DataSource

getInstance

static
Class Method
getInstance(): DataSourceManager

Return the instance of DataSourceManager. If the instance is not created, it will create a new one. If the instance is created, it will return the existing one. The instance is shared by the app and the builder.

Returns 
DataSourceManager

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.