-
Notifications
You must be signed in to change notification settings - Fork 222
/
Copy pathdatasource.ts
40 lines (35 loc) · 1.27 KB
/
datasource.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Entity } from './collections';
import { Address } from './numbers';
/** Host interface for managing data sources */
export declare namespace dataSource {
function create(name: string, params: Array<string>): void;
function createWithContext(name: string, params: Array<string>, context: DataSourceContext): void;
// Properties of the data source that fired the event.
function address(): Address;
function network(): string;
function context(): DataSourceContext;
}
export namespace dataSource {
export function stringParam(): string {
return String.UTF8.decode(dataSource.address().buffer);
}
}
/** Context for dynamic data sources */
export class DataSourceContext extends Entity {}
/**
* Base class for data source templates. Allows to dynamically create
* data sources from templates at runtime.
*/
export class DataSourceTemplate {
/**
* Dynamically creates a data source from the template with the
* given name, using the parameter strings to configure the new
* data source.
*/
static create(name: string, params: Array<string>): void {
dataSource.create(name, params);
}
static createWithContext(name: string, params: Array<string>, context: DataSourceContext): void {
dataSource.createWithContext(name, params, context);
}
}