Fork me on GitHub
#keechma
<
2020-07-25
>
beders20:07:15

hey there, is there an example for keechma/next that shows how to use it with reagent?

mihaelkonjevic21:07:24

@nha I’m definitely following trends here 😄

🙂 3
mihaelkonjevic21:07:46

@beders not right now, but it shouldn’t be too hard. There are two options: 1. Sync whole state to the reactive atom and then use reagent’s reactions to implement subscriptions and similar features 2. Use keechma’s subscription system and sync subscriptions with reagent Option 1 is not possible atm - there is no way to sync whole state, but option 2 should be very easy to implement. I can create an example tomorrow

beders21:07:31

How are you guys currently rendering an UI?

mihaelkonjevic21:07:57

This repo has all the code that will be extracted and released over next few weeks, it needs to be cleaned up and documented

beders22:07:11

Ah, ok, so you are using hooks.

mihaelkonjevic22:07:13

for Helix, the integration is done through hooks

beders22:07:15

Thanks for posting this

beders22:07:24

I'll check out helix

beders22:07:52

can't say if I'm a fan of hooks yet or not, but I definitely like keechma controllers

mihaelkonjevic22:07:46

For us they are a great solution because we get closer integration with React, and we’re handling reactivity on our own now anyway, so Reagent is an overkill. If you want to try it out real quickly with reagent something like this might work:

(defn my-comp []
  (reagent/with-let [local-state (reagent/atom nil)
                     unsubscribe (keechma/subscribe app-instance :controller-name #(reset! local-state %)]
    ...
    (finally
      (unsubscribe))))

👍 3
beders22:07:49

oh, right, yeah, that's a neat approach

beders22:07:14

thanks so much!

mihaelkonjevic22:07:07

No problem, please mention me when you have a question, I’ll try to answer ASAP. I’m checking this channel periodically, but this will ensure I see it sooner 🙂

beders22:07:53

will do! I guess I need to read up on what react was up to since invention of hooks 😉