Add emitTo to generated event bindings - #249
Open
johncarmack1984 wants to merge 2 commits into
Open
johncarmack1984 wants to merge 2 commits into
johncarmack1984 wants to merge 2 commits into
Conversation
6 tasks
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.
Closes #187.
Note: the first commit here is the snapshot suite from #248, kept so the second commit's fixture diff shows exactly what
emitTochanges in the generated output. If #248 lands first I'll rebase this down to theemitTocommit alone.What changed
emitTo(target, payload)to generated event objects, on both the global form (events.myEvent.emitTo("main", payload)) and the target-scoped form (events.myEvent(webview).emitTo("main", payload)), for TypeScript and JSDocEventEmitTo<T>runtime type mirroringEventEmit<T>'s null-payload handling (unit-payload events take only the target argument)EventEmitToinRESERVED_NDT_NAMES, and also add the previously missingEventEmit, so user types with those names get renamed instead of colliding with the runtimeWhy
emitbroadcasts to all targets; there was no generated way to reachemitTo's targeted delivery, so scoping an event to one window meant dropping back to the untyped API.Validation
cargo test --all-features(the snapshot suite caught the runtime change in every event-bearing scenario; fixtures regenerated)cargo clippy --all-features --all-targets(no warnings),cargo fmt --checktsc --noEmit --stricton the regenerated TypeScript bindings (flat, namespaces, and plugin variants) against@tauri-apps/api2.11.1 —emitToand theEventTargettype check out on the module-level API and theWindow/Webviewclasses--checkJs --strictdiagnostics before and after — none introducedNotes
The custom-plugin example's committed
bindings.tshad drifted behind main (it still had the old single-genericmakeEvent<T>); the regeneration here folds that catch-up in with theemitTochange.