@sigma-plugins/common-services-ng
v1.0.11
Published
Angular services for Sigma plugin development
Readme
@sigma-plugins/common-services-ng
Angular services for Sigma plugin development. This package provides reusable Angular services for common Sigma plugin functionality.
Installation
npm install @sigma-plugins/common-services-ngPeer Dependencies
Make sure you have the following peer dependencies installed:
npm install @angular/core @sigmacomputing/plugin rxjsUsage
Import the Module
Import the CommonServicesNgModule in your Angular module:
import { NgModule } from '@angular/core';
import { CommonServicesNgModule } from '@sigma-plugins/common-services-ng';
@NgModule({
imports: [
CommonServicesNgModule,
// other imports...
],
// ...
})
export class AppModule { }Using Individual Services
You can also import and use individual services:
import { Injectable } from '@angular/core';
import { ConfigService, ElementDataService, VariableService, PluginService } from '@sigma-plugins/common-services-ng';
@Injectable()
export class MyService {
constructor(
private configService: ConfigService,
private elementDataService: ElementDataService,
private variableService: VariableService,
private pluginService: PluginService
) {}
}Services
ConfigService
Manages plugin configuration and provides reactive access to configuration changes.
Methods:
getConfig(): Observable<any>- Get the full configuration objectgetConfigKey(key: string): Observable<any>- Get a specific configuration key
Example:
this.configService.getConfig().subscribe(config => {
console.log('Current config:', config);
});
this.configService.getConfigKey('allowExpansion').subscribe(value => {
console.log('Allow expansion:', value);
});ElementDataService
Manages workbook element data subscriptions for different configuration IDs.
Methods:
getElementData(configId: string): Observable<WorkbookElementData>- Subscribe to element data changes
Example:
this.elementDataService.getElementData('source').subscribe(data => {
console.log('Element data:', data);
});VariableService
Manages workbook variables with reactive subscriptions and synchronous access.
Methods:
getVariable(id: string): Observable<WorkbookVariable | undefined>- Subscribe to variable changessetVariable(id: string, ...values: unknown[]): void- Set variable valuegetVariableValue(id: string): WorkbookVariable | undefined- Get current value synchronously
Example:
// Subscribe to variable changes
this.variableService.getVariable('taskIdControl').subscribe(variable => {
console.log('Variable value:', variable?.value);
});
// Set variable value
this.variableService.setVariable('taskIdControl', 'task1,task2,task3');
// Get current value synchronously
const currentValue = this.variableService.getVariableValue('taskIdControl');PluginService
Provides access to the Sigma plugin client instance.
Methods:
getPluginInstance()- Get the Sigma plugin client instance
Example:
const client = this.pluginService.getPluginInstance();
// Use client for direct plugin API accessDevelopment
Building
npm run buildBuilding TypeScript only
npm run build:tscLicense
MIT
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
