Skip to content

Implement MessageCommand Interfaces per Enumeration #669

@stricklandrbls

Description

@stricklandrbls

Issue

The MessageCommand enumeration represents the potential message types that are communicated back and forth, via websockets, between the dataEditorClient object and its WebViewPanel.

Svelte components append an event listener to the DOM that listen for different enumerations of MessageCommand and act accordingly. Though, developers are unable to confidently index into the msg.data.data object because that portion of the message is always initialized inline.

Example

vscode.postMessage({
    command: MessageCommand.testCommand ,
    data: {
        a: 'a',
        b: 'b',
    }
})

Because of this, there is no index / intellisense relating to the data object.

Solution

Create and implement an interface, type, or data structure that would allow a developer to type cast the data portion of the VSCode message and accurately determine the structure of each MessageCommand enumeration.

Example
Receiving a message.

  window.addEventListener('message', (msg) => {
    switch (msg.data.command) {
      case MessageCommand.test:
        const data = msg.data.data as TestCommand
        ...

Metadata

Metadata

Labels

code qualityIssues related to code qualitydata editorIssues related to the Data Editor capability

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions