bluerobotics / bluerobotics/cockpit

All widgets that use options re-implement the same pattern

Open
#311 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
198
Forks
63
Avg merge
2d 7h
Merged PRs (30d)
57

Description

If a widget wants to access its options, it needs to implement the following code:

```typescript
const props = defineProps<{
/**
* Widget reference
*/
widget: Widget
}>()

const widget = toRefs(props).widget

onBeforeMount(() => {
// Set initial widget options if they don't exist
if (Object.keys(widget.value.options).length === 0) {
widget.value.options = {
...
}
}
})

```

Those 20 lines are repeated over and over for each component.

It would be cool if we could use something like [Provide/Inject](https://vuejs.org/guide/components/provide-inject.html) to allow the widgets to have those properties without the boilerplate. It is important thought that those are reactive.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the widget components that repeat the shown props, toRefs, and onBeforeMount pattern, then read Vue's Provide/Inject guidance linked in the issue. Done means widgets access shared options through a reusable mechanism, the options remain reactive, and the repeated boilerplate is removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.