Repository navigation
[FSSDK-12296] Async Hook implementation - #324
Merged
Md Junaed Hossain (junaed-optimizely) merged 5 commits intoApr 7, 2026
Merged
Md Junaed Hossain (junaed-optimizely) merged 5 commits into
Md Junaed Hossain (junaed-optimizely) merged 5 commits into
Conversation
Md Junaed Hossain (junaed-optimizely)
requested review from
Copilot and
Raju Ahmed (raju-opti)
April 3, 2026 12:22
There was a problem hiding this comment.
Pull request overview
Adds async counterparts to the existing “decide” React hooks so consumers can evaluate flags via the Optimizely SDK’s async decide APIs (needed for CMAB / async decisioning) while handling loading/error states, cancellation, and forced-decision reactivity.
Changes:
- Introduces
useDecideAsync,useDecideForKeysAsync, anduseDecideAllAsyncand exports them from the public entrypoints. - Adds shared
useAsyncDecisionstate machine to manage async execution, cancellation of stale promises, and store readiness transitions. - Adds comprehensive Vitest coverage for the 3 new hooks and extends hook test utilities with async decide method stubs.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.ts | Exports the new async hooks from the package entrypoint. |
| src/hooks/index.ts | Exposes the new async hooks (and related types) from the hooks barrel. |
| src/hooks/useAsyncDecision.ts | Adds shared async state machine used by all async decide hooks. |
| src/hooks/useDecideAsync.ts | Implements async single-flag decision hook w/ forced decision subscription. |
| src/hooks/useDecideForKeysAsync.ts | Implements async multi-key decision hook w/ per-key forced decision subscription. |
| src/hooks/useDecideAllAsync.ts | Implements async all-flags decision hook w/ global forced decision subscription. |
| src/hooks/*.spec.tsx | Adds tests covering readiness states, cancellation, re-evaluation triggers, and forced-decision reactivity. |
| src/hooks/testUtils.tsx | Extends mock user context to support async decide APIs for testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Raju Ahmed (raju-opti)
approved these changes
Apr 7, 2026
Raju Ahmed (raju-opti)
left a comment
Contributor
There was a problem hiding this comment.
Some small suggestions
Md Junaed Hossain (junaed-optimizely)
merged commit Apr 7, 2026
9c77bfd
into
master
10 checks passed
Md Junaed Hossain (junaed-optimizely)
deleted the
junaed/fssdk-12296-async-hook-impl
branch
April 7, 2026 15:46
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.
Summary
useDecideAsync,useDecideForKeysAsync, anduseDecideAllAsynchooks — async counterparts to the existing sync decide hooks, required for CMAB, async UPS etc.Test plan
Issues