-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add routing of messages between the property inspector and the plugin #33
Conversation
…aries Sadly, when utilizing rollup-plugin-dts to bundle declarations into a single file, summaries for "export import *" were being lost. This result in quiet issues when creating the .d.ts file, so has [temporarily] been removed.
… of summaries" This partially reverts commit b91556f.
LICENSE
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 2024 required here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot, re-added.
src/common/messaging/gateway.ts
Outdated
* @param options Optional routing configuration. | ||
* @returns This instance with the route registered. | ||
*/ | ||
public route<TBody extends JsonValue = JsonValue>(path: string, handler: UnscopedMessageHandler<TAction, TBody>, options?: RouteConfiguration<TAction>): this { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there ever any circumstance where we might want to allow a route to be unregistered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is, but not at the moment. When transient actions are available, and they're added / removed from memory as needed, we'll need to ensure the routes for those context/action combinations are also removed appropriately. This also drove the decision to not return this
on the publicly exposed registerRoute
as that will likely return a Disposable
to allow for the route to be removed.
streamdeck/src/plugin/ui/controller.ts
Lines 77 to 83 in d41df3a
public registerRoute<TBody extends JsonValue = JsonValue, TSettings extends JsonObject = JsonObject>( | |
path: string, | |
handler: MessageHandler<TBody, TSettings>, | |
options?: RouteConfiguration<Action> | |
): void { | |
router.route(path, handler, options); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registerRoute
now returns an IDisposable
🥳
Adds routing of messages between the plugin and its property inspector.
Example
Plugin
Property Inspector Side
Changes
Plugin
PropertyInspector
class.fetch
to fetch requests from the property inspector.streamDeck.ui.current
to track the current property inspector.streamDeck.ui.registerRoute
to register the routing of requests from the property inspector.@route
decorator to provide routing of an action's function.sendToPlugin
andsendToPropertyInspector
as deprecated.Property Inspector
streamDeck.plugin fetch
to send fetch requests to the plugin.streamDeck.plugin.registerRoute
to register the routing of requests from the plugin.sendToPlugin
andsendToPropertyInspector
as deprecated.Internal
MessageGateway
class for handling bi-directional requests / responses.