-
Notifications
You must be signed in to change notification settings - Fork 8
Common TypeScript Use Cases
Casper Thule edited this page Jun 11, 2018
·
1 revision
The paths used below are relative to the file your are working in.
Type imports:
import {IntoCpsApp} from "../IntoCpsApp"
Example:
/// <reference path="../../typings/browser/ambient/github-electron/index.d.ts"/>
/// <reference path="../../typings/browser/ambient/node/index.d.ts"/>
let app : IntoCpsApp = IntoCpsApp.getInstance()
Type imports:
import {IntoCpsApp} from "../IntoCpsApp"
import {IProject} from "../proj/IProject";
Example:
let app : IntoCpsApp = ...
let project = app.getActiveProject();
Type imports:
import {IntoCpsApp} from "../IntoCpsApp"
import * as Main from "../settings/Settings"
import {SettingKeys} from "../settings/SettingKeys";
Example:
let app : IntoCpsApp = ...
let settings = app.getSettings();
settings.setValue(SettingKeys.MY_SETTINGS_KEY,myValue);
let value = settings.getValue(SettingKeys.MY_SETTINGS_KEY);
We recommend that global settings keys are defined in SettingKeys
to avoid duplication.
Type imports:
import * as IntoCpsApp from "../IntoCpsApp"
import {IProject} from "../proj/IProject";
Example:
let project : IProject = ...
let settings = project.getSettings();
settings.setValue("my-settings-json-key",myValue);
let value = settings.getValue("my-settings-json-key");
project.save();