Class WebShareBinding
java.lang.Object
com.vaadin.flow.component.webshare.WebShareBinding
- All Implemented Interfaces:
Serializable
Fluent surface returned from
WebShare.onClick(T), used to declare what a
click should hand to the browser's native share sheet. Call share(com.vaadin.flow.component.webshare.ShareContent)
with the title, text, and/or URL to share. The share runs in the browser at
click time, while the user gesture required by the Web Share API is still
valid.
Actions come in two flavours: fire-and-forget (one argument) and observed
(with onShared/onError callbacks). onShared fires
after the user picks a share target; onError fires when the user
dismisses the sheet (the browser reports AbortError) or when the call
is rejected for other reasons (no gesture, permissions policy block,
unsupported browser). Both consumers are required in the observed form ? pass
() -> {} or err -> {} to opt out of one.
Button share = new Button("Share");
WebShare.onClick(share).share(
ShareContent.create().title("Hello").url("https://vaadin.com"));
WebShare.onClick(share).share(
ShareContent.create().url("https://vaadin.com"),
() -> Notification.show("Shared!"),
err -> Notification.show("Cancelled: " + err.name()));
- Since:
- 25.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidshare(ShareContent content) Invokes the browser's native share sheet with the given content when the underlying trigger fires.voidshare(ShareContent content, SerializableRunnable onShared, SerializableConsumer<PromiseAction.Error> onError) Likeshare(ShareContent)but reports the outcome back to the server.
-
Method Details