Update creating-plugins.md

This commit is contained in:
Seth Burkart
2025-03-18 22:19:32 +11:00
committed by GitHub
parent 1c63c06b72
commit 620d168d28
+6 -6
View File
@@ -65,13 +65,13 @@ const myPlugin: Plugin<MyPluginSettings, MyPluginStorage> = {
// Initialize your settings here // Initialize your settings here
}, },
run: (api) => { run: (api) => {
if (!api.settings.get('enabled')) { if (!api.settings.enabled) {
return; return;
} }
// Initialize storage with default values if needed // Initialize storage with default values if needed
if (api.storage.get('lastRun') === undefined) { if (api.storage.lastRun === undefined) {
api.storage.set('lastRun', new Date().toISOString()); api.storage.lastRun = new Date().toISOString();
} }
// Your plugin logic goes here // Your plugin logic goes here
@@ -147,7 +147,7 @@ api.seqta.onPageLoad('/timetable', () => {
```typescript ```typescript
// Get a setting value // Get a setting value
const isEnabled = api.settings.get('enabled'); const isEnabled = api.settings.enabled;
// Listen for settings changes // Listen for settings changes
api.settings.onChange('enabled', (newValue) => { api.settings.onChange('enabled', (newValue) => {
@@ -163,10 +163,10 @@ api.settings.onChange('enabled', (newValue) => {
```typescript ```typescript
// Get a stored value // Get a stored value
const lastRun = api.storage.get('lastRun'); const lastRun = api.storage.lastRun;
// Set a stored value // Set a stored value
api.storage.set('lastRun', new Date().toISOString()); api.storage.lastRun = new Date().toISOString();
// Listen for storage changes // Listen for storage changes
api.storage.onChange('lastRun', (newValue) => { api.storage.onChange('lastRun', (newValue) => {