#Naming my own primitives - createFoo vs useFoo

8 messages · Page 1 of 1 (latest)

open harbor
#

In vue composables are always named useFoo, ditto for react hooks.
And for svelte stores I like just foo (mirroring the built-in writable and friends) but I feel like createFoo can also be appropriate in some cases.
I kinda sorta get that there's some sort of difference between the frameworks that warrants the different naming conventions but I can't say I truly understand the reasoning behind it.
Is it the vdom vs non-vdom? Or reactivity vs however you call what react does?
The latter kinda makes sense to me except for the fact that vue has a reactivity model more similar to solid than to react but uses use.
Then there's the fact that solid has useAssets and useContext which I guess kinda makes sense since you're using or tapping into something that has already been created/initialized???

vast meadow
#

the use of those words are highly contextual (no puns intended) so choosing between those two (or more, there's a lot more prefix to choose) depends on the nature of the primitive. For example createWebsockets(ws) vs useWebsockets(ws), which makes more sense?

#

for the reasoning behind Solid's create prefixes: Solid primitives aren't tied to a component, and in contrast with hooks, you are "instanciating" more than "getting".

open harbor
tacit ginkgo
#

make nonreactive stuff
create reactive primitives
use contexts

open harbor
#

ah, that's much nicer.

vast meadow
vale dagger
#

use for anything. problem solved