hilla icon indicating copy to clipboard operation
hilla copied to clipboard

JS Typed Arrays (like Uint8Array) should be supported

Open vlukashov opened this issue 6 years ago • 3 comments
trafficstars

When transferring primitive array-like data using Connect endpoints, I want primitive Java arrays like byte[] to be mapped to typed JS arrays like Int8Array, 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.

Example:

@VaadinService
public class DataService {
    public void foo(byte[] data) {
    }
}
export function foo(
  data: Int8Array
): Promise<void>

source

vlukashov avatar Nov 08 '19 08:11 vlukashov

The first solution could be based on base64 encoding, later it can be improved to multi-part requests.

haijian-vaadin avatar Feb 20 '20 12:02 haijian-vaadin

Would be good to add support for Int8Array/byte[] to @ClientCallable as well.

mvysny avatar Nov 04 '20 14:11 mvysny

@ClientCallable is a completely separate thing from the implementation point of view. Could you please create a separate ticket about that?

Legioth avatar Nov 18 '20 11:11 Legioth