Best practice for supporting static and reactive args
If I want to create a reactive function that takes in either a static or reactive arg like this:
I always wondered if there's a better alternative to
string | Accessor<string>
to support the following static and reactive scenarios:
2 Replies
Yes, I wonder too if there is some kind of standard utiltiy for this
I have
AccessorMaybe<T> = Accessor<T> | T type util and const resolve = (fn: AccessorMaybe<T>): T => typeof fn === 'function' ? fn() : fn that I use a lot