plugins: doc for new api.events

Massimo Melina committed May 12, 2024 at 12:02 UTC ee4549c8f5c10ffa39869eb5c296aa46045b9fa2
1 file changed +22 -10
dev-plugins.md
+22 -10
@@ -171,7 +171,18 @@ The `api` object you get as parameter of the `init` contains the following:
171 - `storageDir: string` folder where a plugin is supposed to store run-time data. This folder is preserved during
172 an update of the plugin, while the rest could be deleted.
173
174 -- `events: EventEmitter` this is the main events emitter used by HFS.
174 +- `events` this is the main events emitter used by HFS.
175 + These are backend side events, not to be confused with frontend ones. It's not the standard EventEmitter class,
176 + and the API is slightly different.
177 +
178 + - `events.on(name: string, listener: Callback): Callback`
179 +
180 + call your listener every time the event is emitted.
181 + The returned callback will unsubscribe the event.
182 +
183 + - `events.once(name: string, listener?: Callback): Promise<eventArguments>`
184 +
185 + when the event is emitted, your (optional) listener is called, and the returned promise is resolved.
186
187 - `require: function` use this instead of standard `require` function to access modules already loaded by HFS. Example:
188 ```js
@@ -425,23 +436,24 @@ If you want to override a text regardless of the language, use the special langu
436
437 - 8.81 (v0.53.0)
438 - api.openDb
428 - - new event: menuZip
429 -- config.type:username
439 + - frontend event: menuZip
440 + - config.type:username
441 + - api.events class has changed
442 - 8.72 (v0.52.0)
443 - HFS.toast
444 - HFS.misc functions
445 - HFS.state.uri
434 - - ~~new event: uriChanged~~
446 + - ~~frontend event: uriChanged~~
447 - 8.65 (v0.51.0)
448 - plugin's own hfs-lang files
449 - HFS.state.props.can_overwrite
450 - ctx.state.considerAsGui
439 - - new event: userPanelAfterInfo
451 + - frontend event: userPanelAfterInfo
452 - breaking: moved custom properties from ctx to ctx.state
453 - HFS.navigate
454 - internationalization
455 - 8.5 (v0.49.0)
444 - - new event: entry
456 + - frontend event: entry
457 - exports.onDirEntry: entry.icon
458 - customApiCall supports any number of parameters
459 - 8.4 (v0.48.2)
@@ -456,7 +468,7 @@ If you want to override a text regardless of the language, use the special langu
468 - HFS.watchState, emit, useApi
469 - api.storageDir, customApiCall
470 - exports.depend
459 - - new event: fileShow
471 + - frontend event: fileShow
472 - 8.1 (v0.45.0) should have been 0.44.0 but forgot to update number
473 - full URL support for frontend_js and frontend_css
474 - custom.html
@@ -464,18 +476,18 @@ If you want to override a text regardless of the language, use the special langu
476 - HFS.apiCall, reloadList, logout, h, React, state, t, _, dialogLib, Icon, getPluginPublic
477 - second parameter of onEvent is now deprecated
478 - renamed: additionalEntryProps > additionalEntryDetails & entry-props > entry-details
467 - - new event: entryIcon
479 + - frontend event: entryIcon
480 - 8 (v0.43.0)
481 - entry.name & .uri
482 - tools.dialogLib
483 - HFS.getPluginConfig()
484 - 7 (v0.42.0)
473 - - new event: fileMenu
485 + - frontend event: fileMenu
486 - HFS.SPECIAL_URI, PLUGINS_PUB_URI, FRONTEND_URI,
487 - 6 (v0.38.0)
488 - config.frontend
489 - 5 (v0.33.0)
478 - - new event: afterEntryName
490 + - frontend event: afterEntryName
491 - 4.1 (v0.23.4)
492 - config.type:array added $width, $column and fixed height
493 - 4 (v0.23.0)