Skip to content

A way to detect a composable is being used in setup store #2713

Closed Answered by posva
MartinMalinda asked this question in Help and Questions
Discussion options

You must be logged in to vote

You can use getCurrentScope() to know if you are within an effect scope.

You shouldn't need pinia as a dependency, that's for sure. In library code, you can check for a currentInstance and conditionally setup hooks if needed but for onUnmounted() you can also use onScopeDispose(). This should make your library work with libraries other than Pinia that use the same pattern

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@MartinMalinda
Comment options

Answer selected by MartinMalinda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2712 on July 12, 2024 09:59.