Open mvysny opened 4 years ago
Slightly related. I have recently started to use CustomEvent more than @ClientCallable methods for client->server communication (supports throttling/debouncing). For my helper I just added byte[]
support.
Usage example from the client side:
The target.value on the piggybacked event is DataView (which contains buffer), base64 encoded like this:
// base64 encoded DataView
const b64 = b => btoa(String.fromCharCode(...new Uint8Array(b.buffer)));
This is probably "good enough" for most cases. If there are really big binaries, sending them as raw http request probably is the way to go, a "bigger" framework feature for that would be needed.
When transferring primitive array-like data using
@ClientCallable
(or other Flow data passing mechanisms), I want primitive Java arrays likebyte[]
to be mapped to typed JS arrays likeUInt8Array
, so that (a) the transfer is more efficient in terms of how many bytes are sent over the wire and (b) I do not have to write the boilerplate code to convert from a typed array into an regular JS array of numbers.Similar to vaadin/hilla#350 but this ticket relates to
@ClientCallable
.