Check if value is a Solid signal #2146
Unanswered
magicmatatjahu
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
HI! I am wondering if there's a possibility to check if value passed to function is a Solid signal. As I see, all getter of signal is a bounded
readSignal
function, however, it's not possible to check the original function from the getter. E.g. Angular provides a functionisSignal
and based on that, you can read the state from the signal by calling it or through the functionuntracked
- if you want to get out of reactivity system.Background: I'm writing SolidJS integration for my library, and in 99% of cases my API won't need reactivity (because the function result should be 99% static across component), whereas if a signal is used as argument (via a getter reference, not a value) the function result could be changed to a signal (based on TS overload types).
Atm I can do it in this way, to override native
.bind
function:but it's very ugly solution, because all
.bind
calls in code will have an above side effect and alsorecognizeSignal
function needs to be called before any previous code.If a similar question has already been asked before, sorry for unnecessary post and would ask for a link to the discussion/issue, thanks!
Beta Was this translation helpful? Give feedback.
All reactions