You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ts): forward per-call hook options through predictBatch - #936
TypeScript Router.predictBatch and predictMany accept onPredictStart, onPredictEnd and hooksRaise, and compose them the way Router.predict does. hooksRaise also applies to onRoute. This is the TypeScript counterpart of the Python predict_batch hook forwarding in #912.
Why
predictBatch only composed opts.hooks and always used the Router's hooksRaise, so a per-call start or end hook was dropped and a per-call hooksRaise: false was ignored. predictMany forwards to predictBatch, so it had the same gap.
How it was verified
cd laya-ts && npm ci && npm test -- --run && npx tsc --noEmit
python tests/test_router.py
ruff check laya/ --select=E9,F63,F7,F82,F401,F811 --line-length=120
Merged, and this is the one of the two fixes for #935 that went in.
What decided it: besides the composition at the dispatch site, this also forwards hooksRaise into the routeBatch call, so a per-call hooksRaise: false reaches onRoute and not only the predict lifecycle. #943 fixes the dispatch site identically but leaves onRoute on the router-level flag. The README update is the other half, since predictBatch's documented hook surface was the thing that disagreed with predict.
#943 does have two tests this does not, and they are worth having: a per-call hooksRaise: true turning raising back on where the router has it off, and an assertion that a per-call callback runs after a per-call hooks entry rather than merely that both ran. I have asked there for them as a test-only follow-up.
Merge note: this conflicted with #929, which rewrote the same docblock. I kept #929's sentence about setDefaultHooks defaults and extended it to name your two callables, so the comment now reads defaults, then installed, then this call's hooks, then onPredictStart / onPredictEnd. Worth confirming it still matches the code.
Verified on the merged tree: 654 TypeScript tests pass across 34 files, tsc --noEmit clean, all 81 Python suites pass.
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
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.
What
TypeScript
Router.predictBatchandpredictManyacceptonPredictStart,onPredictEndandhooksRaise, and compose them the wayRouter.predictdoes.hooksRaisealso applies toonRoute. This is the TypeScript counterpart of the Pythonpredict_batchhook forwarding in #912.Why
predictBatchonly composedopts.hooksand always used the Router'shooksRaise, so a per-call start or end hook was dropped and a per-callhooksRaise: falsewas ignored.predictManyforwards topredictBatch, so it had the same gap.How it was verified
Vitest: 34 files, 632 passed.
tsc --noEmit: clean.python tests/test_router.py: 703 passed, 0 failed. Ruff: all checks passed.Checklist
mainFixes #935