Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unique registration action for each createThunk instance #46

Closed
wants to merge 6 commits into from

Conversation

VldMrgnn
Copy link
Collaborator

This PR introduces a test to verify that the API is called only once, even if it is registered twice.
It also suggests a solution by checking for the existence of the signal before registering it.
I am not fully certain about the deeper implications of this change, and further reviews are certainly needed.

@VldMrgnn
Copy link
Collaborator Author

Concept: Unique Actions for a Unique Register

  1. Every time createThunks() is called, we generate a unique instanceId to identify each thunk instance.

  2. To ensure idempotency, we use a registrationMap that tracks whether each createThunks instance has been registered. This check and registration happen in the function* register().

  3. The main idea is to create a unique registration action for each createThunks instance. Instead of using a generic action like ${API_ACTION_PREFIX}REGISTER_THUNK, we use a distinctive action like ${API_ACTION_PREFIX}REGISTER_THUNK_${instanceId}. This ensures each thunk instance gets its own watcher, which listens only for its specific registration action.

@VldMrgnn VldMrgnn changed the title Thunk test fix: unique registration action for each createThunk instance Sep 11, 2024
@VldMrgnn
Copy link
Collaborator Author

I will close this PR and open a new one with a clean branch that contains only the relevant changes. Thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant