Closed GuiLeme closed 2 months ago
Hello @GuiLeme - I think it's a great idea, because with arrays, in order to access the third or fourth element, you need to specify the second one, which is painful.
It will require a rewrite of the current plugins, but it's very minor (just change the way it destructure the hook return), and as we didn't released the BBB 3.0 yet, it seems a good moment to do this refactor.
What is the idea?
Basically I would like to change the return type of the
useDataChannelFunction
, because we changed the philosophy of that hook. At the beginning of its development, we intended to mimic the behavior ofReact.useState
, so we had something like[state, setState] = useDataChannel<type>(...)
.But since then, we added the
delete
function, and now anupdate
one, and therfore we have a 4-item array, as demonstrated below:This is a bit difficult to manipulate, mainly because if we want to get all the items except for one in the middle, for instance, the delete function, we would still have to declare it, and have lint errors in typescript.
So the idea is that now, instead of having an array as the return, we could simply have an object, this way, we can select only the properties that we want. As an example, I am going to show a before/after of a code using the data-channel:
Before:
After: