You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say we have a plugin for Discord notifications - it knows how to interact with the Discord API and push messages to a channel. Then we have another plugin that monitors free disk space. The author of this plugin wants the user to be able to get notifications when the disk space runs low.
With a simple message bus thingy we can decouple this, and let plugins interact without being directly aware of eachother.
The Discord plugin would look something like this,
localbus=require"bus"functionporla.init()
bus.on("user.notify", function (args)
sendDiscordNotification(args.message)
end)
end
It would basically listen on a pre-defined "channel" and then provide a callback that is invoked.
This allows other plugins, like the theoretical disk space monitor, to do something like this,
localbus=require"bus"functionwarnSpaceLow()
bus.publish("user.notify", { message="Disk space is running low!" })
end
Porla needs to decide on some pre-defined channels for user notifications etc, but nothing stops plugins from listening on their own channels to do plugin-specific things.
Getting this in place makes it easier for plugin authors to focus on what their own plugin should do, for example the Discord plugin can focus on Discord notifications. It also let's the user switch out the Discord plugin for other types of plugins that also handle the user.notify channel if they want their notifications elsewhere.
The text was updated successfully, but these errors were encountered:
Let's say we have a plugin for Discord notifications - it knows how to interact with the Discord API and push messages to a channel. Then we have another plugin that monitors free disk space. The author of this plugin wants the user to be able to get notifications when the disk space runs low.
With a simple message bus thingy we can decouple this, and let plugins interact without being directly aware of eachother.
The Discord plugin would look something like this,
It would basically listen on a pre-defined "channel" and then provide a callback that is invoked.
This allows other plugins, like the theoretical disk space monitor, to do something like this,
Porla needs to decide on some pre-defined channels for user notifications etc, but nothing stops plugins from listening on their own channels to do plugin-specific things.
Getting this in place makes it easier for plugin authors to focus on what their own plugin should do, for example the Discord plugin can focus on Discord notifications. It also let's the user switch out the Discord plugin for other types of plugins that also handle the
user.notify
channel if they want their notifications elsewhere.The text was updated successfully, but these errors were encountered: