When using the hook useDataChannel the function oblige the developer to use a generic, so that the data it will receive will come in certain pattern. But it seems that all the returns of the hook already come within a very structured pattern, like so:
Now, this is the structure that we receive inside the data property of the GraphqlResponseWrapper, and so it would be easier for the developer to already have this in the palm of their hands than trying to guess what the return will be.
Changes:
So, the way we have now, we need to construct the pluginDataChannelMessage interface and also the wrapping structure, and within that, we can pass the data we are interested in. For instance, if we want to pass a PickedUser in the dataChannel, now we would need to do the following:
And than if we want another dataChannel, we would have to either recreate the DataThatWeReceive interface with the new payload we want or make it generic (because the overall structure is precisely the same).
Brief description
When using the hook
useDataChannel
the function oblige the developer to use a generic, so that the data it will receive will come in certain pattern. But it seems that all the returns of the hook already come within a very structured pattern, like so:Now, this is the structure that we receive inside the
data
property of theGraphqlResponseWrapper
, and so it would be easier for the developer to already have this in the palm of their hands than trying to guess what the return will be.Changes:
So, the way we have now, we need to construct the pluginDataChannelMessage interface and also the wrapping structure, and within that, we can pass the data we are interested in. For instance, if we want to pass a
PickedUser
in the dataChannel, now we would need to do the following:What we have:
And than if we want another dataChannel, we would have to either recreate the
DataThatWeReceive
interface with the new payload we want or make it generic (because the overall structure is precisely the same).What we want: