feat: add eval_with_callback to Webview and WebviewWindow#14925
Open
lanyeeee wants to merge 1 commit intotauri-apps:devfrom
Open
feat: add eval_with_callback to Webview and WebviewWindow#14925lanyeeee wants to merge 1 commit intotauri-apps:devfrom
eval_with_callback to Webview and WebviewWindow#14925lanyeeee wants to merge 1 commit intotauri-apps:devfrom
Conversation
Contributor
Package Changes Through e6b376bThere are 3 changes which include tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
Author
|
There are two test failures in this run, but they appear to be flaky. I pushed the exact same commit to my fork and all tests passed there without issues. Could you please re-run the GitHub Actions? @FabianLars |
Member
|
don't worry about it. the android builds regularly fail cause the cache breaks for some reason. meant to delete the caches for another PR but the mobile gh app is horrible x) will do now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #5441
This PR adds a new method
eval_with_callbackto tauri::webview::Webview and tauri::webview::WebviewWindow, providing a way to evaluate JavaScript in the webview and receive the evaluation result (serialized as a JSON string) via a callback function.The feature addresses the long-standing request in #5441
The change is non-breaking, fully backward-compatible, and ready for integration.
Implementation Details
eval_script_with_callbackto the tauri_runtime::WebviewDispatch trait.handle_user_messageby forwarding towry::WebView::evaluate_script_with_callback.eval_with_callbackon both tauri::webview::Webview and tauri::webview::WebviewWindow.The implementation closely follows the existing pattern for
eval_scriptto ensure consistency, minimal code duplication, and proper tracing span propagation when thetracingfeature is enabled.Platform Support (Android)
The underlying wry::WebView::evaluate_script_with_callback method is documented as "Android: Not implemented yet."
In my own real-world testing on Android devices, the method actually works correctly — the callback is invoked with the expected JSON-serialized result, and no errors occur.
However, to respect the wry documentation and avoid promising unsupported behavior,
eval_with_callbackdocumentation includes the same warning: "Android: Not implemented yet." Users should be aware that while it may work in practice (as verified in testing), it is not officially guaranteed by wry.Tested Example
The following command was tested successfully on both Windows and Android, correctly returning the evaluated result on both platforms: