Update readme.md, docs/api.md files
This commit is contained in:
parent
1d436da13c
commit
277d1cdc92
51
docs/api.md
Normal file
51
docs/api.md
Normal file
|
@ -0,0 +1,51 @@
|
|||
# LMathPluginAPI
|
||||
|
||||
This is a documentation-ish for the `LMathPluginAPI` object, revealed to plugins at the init phase.
|
||||
|
||||
## Common
|
||||
These methods and variables are available on both the backend part and the frontend part.
|
||||
|
||||
### api.getLogger()
|
||||
Returns the `log4js` logger.
|
||||
|
||||
### api.getVersion()
|
||||
Returns current L'Math version.
|
||||
|
||||
### api.getSettings()
|
||||
Returns the settings object. If you need to modify settings, please see ___ (WIP).
|
||||
|
||||
### api.getUserSetting()
|
||||
Returns the user settings object. If you need to modify settings, please see ___ (WIP).
|
||||
|
||||
----
|
||||
|
||||
### api.events
|
||||
The event-specific API
|
||||
#### events.on(eventName, callback)
|
||||
Allows you to listen to L'Math-specific events.
|
||||
#### events.fire(eventName, eventData)
|
||||
Allows you to fire a custom-named event. The data will be passed as
|
||||
|
||||
----
|
||||
|
||||
### api.messages
|
||||
The messaging-specific API
|
||||
#### messages.on(messageName, callback)
|
||||
Allows you to listen to plugin-specific IPC messages between the backend and the frontend.
|
||||
Any data sent will be passed as an argument to the callback function.
|
||||
**Just like with regular ipc messaging, you can't send functions or other non-json types.**
|
||||
#### messages.send(messageName, messageData)
|
||||
Allows you to send plugin-specific IPC messages between the backend and the frontend.
|
||||
The messageData object will be converted to JSON and passed as a parsed object to any listeners on the other process.
|
||||
**Just like with regular ipc messaging, you can't send functions or other non-json types.**
|
||||
|
||||
|
||||
|
||||
## Backend
|
||||
|
||||
### events
|
||||
|
||||
## Frontend
|
||||
|
||||
### events
|
||||
|
|
@ -60,3 +60,7 @@ L'Math consists of two parts: the node.js backend and the Electron frontend.
|
|||
Even though L'Math isn't sandboxed and node.js integration is allowed on the frontend,
|
||||
it is highly recommended to use the messaging channel provided by the plugin API.
|
||||
The plugin api uses the ipc messaging channel, and its sole purpose is to enable communicate between the two processes.
|
||||
|
||||
## The plugin API
|
||||
Horribly bad documentation is available [here](docs/api.md).
|
||||
Feel free to take a look at the [example plugin](example/).
|
||||
|
|
Loading…
Reference in New Issue
Block a user