Skip to content

Conversation

@KillariDev
Copy link
Collaborator

No description provided.

Comment on lines +19 to +22
const setupInner = (optional: OptionalSignal<any>) => {
const inner = optional.peek()
if (inner !== undefined) subscribeTo(inner, run)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to unsubscribe to the inner if the outer signal value changes from defined to undefined.
Also, no any.

Suggested change
const setupInner = (optional: OptionalSignal<any>) => {
const inner = optional.peek()
if (inner !== undefined) subscribeTo(inner, run)
}
const setupInner = (optional: OptionalSignal<unknown>) => {
const inner = optional.peek()
if (inner === undefined) /*TODO: unsubscribe inner*/
else subscribeTo(inner, run)
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unsubs are done at the end:

return () => {
			cleanupFns.forEach(fn => fn())
			abortController.abort()
		}
		```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is too late. You need to unsubscribe from the inner signal anytime the outer signal changes to undefined. You'll then resubscribe to the inner signal when the outer signal changes back to defined. You already have the resubscribe setup correctly, but without the unsubscribe you'll end up subscribing many times. You'll also incorrectly receive update notifications when nothing has changed.

daiApprovedForRouter.deepValue = await getAllowanceErc20Token(maybeWriteClient, DAI_TOKEN_ADDRESS, maybeWriteClient.account.address, router)
sharesApprovedToRouter.deepValue = await isErc1155ApprovedForAll(maybeWriteClient, AUGUR_SHARE_TOKEN, maybeWriteClient.account.address, router)
}
useSignalEffectWithAbortOnChange([maybeWriteClient] as const, (_abortSignal, ...params) => updateAccountSpecificSignals(...params), console.error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll start using the abort later I assume? Without using the abort, I'm not sure we gain much by switching.

Base automatically changed from hash-routing-fix,-clean-fetching to main May 16, 2025 10:39
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.

3 participants