This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-18
Channels
- # announcements (9)
- # atom-editor (29)
- # aws (17)
- # babashka (72)
- # beginners (83)
- # braveandtrue (3)
- # calva (7)
- # cider (16)
- # clj-kondo (15)
- # cljs-dev (146)
- # cljsjs (1)
- # cljsrn (8)
- # clojars (1)
- # clojure (96)
- # clojure-dev (19)
- # clojure-europe (53)
- # clojure-losangeles (1)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (235)
- # clojuredesign-podcast (5)
- # clojurescript (81)
- # conjure (73)
- # cursive (7)
- # data-science (1)
- # datomic (5)
- # defnpodcast (8)
- # emacs (3)
- # figwheel-main (34)
- # fulcro (83)
- # graalvm (10)
- # graphql (6)
- # helix (49)
- # jackdaw (3)
- # jobs (1)
- # joker (1)
- # kaocha (1)
- # mid-cities-meetup (10)
- # off-topic (17)
- # pathom (16)
- # re-frame (11)
- # reagent (18)
- # reitit (18)
- # remote-jobs (4)
- # shadow-cljs (63)
- # spacemacs (18)
- # specter (20)
- # sql (17)
- # uncomplicate (1)
- # vim (28)
- # xtdb (32)
Hello, I'm pretty new to ClojureScript and I'd like to start a new project with it, I came across this library, how would one manage a state in helix
?
you can check out the docs here: https://github.com/Lokeh/helix/blob/master/docs/hooks.md#maintaining-state
oh, yeah well I'm a react developer for the past 7 years. I know how to manage state in react's world. however in clojurescript I, for some reason, imagined to myself that there are solutions.
like I said, helix is meant to be a very thin wrapper. local component state works great for a majority of cases.
but I would say that being in the same position as you are, started cljs recently in a more serious manner and did lots of react before already, being able to just use hooks and functional components really simplified a lot
if you’re looking for a global state management solution, helix doesn’t have one built in other than what React gives you
I'm just trying to figure what will work best for me and honestly I feel kind of lost, I mean if i'd like to use a library like effector
so I'll need to convert cljs to js everytime right?
I mean, I could manage without a global state, I just think it will be bit of a hustle
React context is very non-efficient though, it will render every listener even if the bit that changed does not concern that listener
yeah. it’s a tradeoff: less complexity / dependencies, but worse out of the box performance
I agree with being lost w.r.t. making decisions about picking libs for managing state 😅
which is why I don’t really suggest anything other than React right now, since it’s a lot easier to migrate away from that if it becomes bad
if you start with React Context, wrapped in a custom hook, it’s easier to refactor that to use e.g. re-frame, effector, or even just a CLJS atom with a watcher
The only reason I didn't go with reagent
is that it won't leverage the functional components of react.
@eliraz.kedmi157 If you’re willing to pre-alpha-test something, I’m working on https://github.com/orestis/reseda . The whole thing is 200-300 lines of code, so you should be able to just fork or copy the relevant bits at some point.
No promises that this is even makes sense but as @lilactown says the API is what matters — you can easily replace the underlying bits.
Here’s the Reagent BMI demo, converted: https://github.com/orestis/reseda/blob/master/src/reseda/demo/bmi.cljs
@lilactown how hard is it to write a wrapper to a js library? I mean, maybe I could wrap effector
? I really like it, I think it's really good.
I understand. BTW, how costly is the conversion from cljs data structures to js objects / arrays? is it being done on runtime?
helix does takes a best-effort approach to do no runtime conversion of immutable data to JS objects / arrays
when defining a component with helix, props get converted to a data type that can be used easily with destructuring/etc. without doing a recursive conversion
it uses cljs-bean: https://github.com/mfikes/cljs-bean
when creating elements, your props will get converted to a JS object automatically. if it can be done, helix will actually rewrite the props map you pass in as a JS object at compilej-time
@eliraz.kedmi157 What has brought you to ClojureScript? Are there some specific problems cljs helps you to solve? You being an experienced React dev, I'd really like to hear your perspective.