Fork me on GitHub
#fulcro
<
2018-02-01
>
tony.kay01:02:27

@levitanong So, I’m playing with react-motion right now, and I don’t see it failing with or without the rebindings. Not sure why…it just seems to work for me out of the box.

tony.kay01:02:58

I guess I can go ahead and release the macro. It at least doesn’t break anything, and it does make sense that the bindings could get lost…so, I’d appreciate feedback about where it is needed and where it isn’t; otherwise I don’t know what to say in docs. I’ll push this demo app to github for anyone to play with.

tony.kay01:02:15

I’m going to continue playing with it…kinda fun 🙂

tony.kay03:02:06

I just added a port of their draggable balls demo as well…just pushed the source and an update to the live version online.

tony.kay03:02:21

So, in general it just seems to work…that macro hasn’t been needed in anything I’ve coded yet.

tony.kay03:02:58

The main pain is just native js interop…e.g. using gobj/get instead of being able to do nice destructuring.

tony.kay04:02:48

Fulcro 2.1.5 released. Includes the with-parent-context macro, and fixes load to work properly with dynamic queries. load now can accept a factory (in lieu of a class) for when you’re using dynamic queries.

levitanong04:02:51

hi @tony.kay sorry for the late reply. Lemme clarify: ReactTransitionGroup contains two APIs: Transition and CSSTransition. The latter is the easy thing because it doesn’t take a function as a child.

levitanong04:02:20

“Are you basically asking how you can use functions as a child?” <-- yes, exactly this.

levitanong04:02:51

Will take a look at the things. 😄

levitanong05:02:02

@tony.kay there is a potential gotcha with with-parent-context. When I implemented it for my project, the CLJ side was complaining because the dynamic vars were private. So I had to do the (:ns &env) check to see if the macro was being called in cljs or clj. If clj, I just skip it all and

`(do ~@body)

levitanong05:02:21

Wicked awesome demos though 😄

tony.kay05:02:55

Ah, I did not try it in cljc, but it should be ok since it is now in the right place for private use

tony.kay05:02:24

@levitanong I could not find a scenario where I needed it, though. Are you doing something with native or something?

levitanong05:02:06

@tony.kay I’m working with web. The usecase is when i’m trying to do SSR

tony.kay05:02:43

Oh, that would have been nice to mention 🙂

levitanong05:02:26

it’s something that’s just always at the back of my mind

levitanong05:02:40

I use a reader conditional to turn react-motion or react-transition-group to divs when in :clj

tony.kay05:02:40

well, if that macro works for your case let me know

tony.kay05:02:04

the clj side could need tuning I guess

levitanong05:02:09

(defmacro with-fulcro-vars
     "These should match the 'render' case in reshape-map.
  Possible gotcha in SSR context."
     [component & body]
     (if-not (:ns &env)
       `(do ~@body)
       `(let [this#       ~component
              reconciler# (or fulcro.client.primitives/*reconciler* (fulcro.client.primitives/get-reconciler this#))
              depth#      (or fulcro.client.primitives/*depth*      (inc (fulcro.client.primitives/depth this#)))
              shared#     (or fulcro.client.primitives/*shared*     (fulcro.client.primitives/shared this#))
              instrument# (or fulcro.client.primitives/*instrument* (fulcro.client.primitives/instrument this#))
              parent#     (or fulcro.client.primitives/*parent*     this#)]
          (binding [fulcro.client.primitives/*reconciler* reconciler#
                    fulcro.client.primitives/*depth*      depth#
                    fulcro.client.primitives/*shared*     shared#
                    fulcro.client.primitives/*instrument* instrument#
                    fulcro.client.primitives/*parent*     this#]
            ~@body))))

levitanong05:02:27

my version looks like this

levitanong05:02:42

this way, it “fails” silently in a CLJ context

tony.kay05:02:39

don't see why it has to fail

levitanong05:02:51

it never has to!

levitanong05:02:00

because you’re the one doing it, and not me!

levitanong05:02:18

The implication of this only hit me now. lol

levitanong05:02:31

… that’s odd.

levitanong05:02:40

java.lang.IllegalStateException: var: fulcro.client.primitives/*reconciler* is not public

levitanong05:02:55

and it’s highlighting my use of prim/with-parent-context

tony.kay05:02:08

OH.....bummer...the macro outputs code 😜

tony.kay05:02:18

so that code is now in your ns

tony.kay05:02:25

ok, that won't work 🙂

levitanong05:02:24

i mean I guess I could always do

#?(:cljs (prim/with-parent-context this (something))
   :clj (something))

tony.kay05:02:52

I should fix it...

tony.kay05:02:21

I think I'm leaning towards your solution...the bindings are not needed in clj

tony.kay05:02:08

try 2.1.6-SNAPSHOT

tony.kay05:02:42

I went ahead and made those dyn vars public. There are extension reasons ppl might want access to them. but, I mainly just adopted your macro.

levitanong05:02:57

Oh, but if you made them public, would there be a need to use my macro?

levitanong05:02:19

or is the decision to use the macro based on the fact that it isn’t needed in CLJ

tony.kay05:02:29

yes, because you don't want to type all of that every time you need it

tony.kay05:02:12

and you need to pick up code and put it in the middle before evaluating it

levitanong05:02:49

ah, i meant the bit with the (:ns &env)

levitanong05:02:02

not the entire macro. Sorry, i was loose with my language

tony.kay05:02:04

that part is useful just because the bindings are not needed in clj

levitanong05:02:16

will try it out now 😄

levitanong05:02:19

@tony.kay works like a charm! thank you 😄

tony.kay08:02:51

@levitanong So, I never did quite understand where you need the bindings. All of my trials of the function as a child pattern work without the wrapper

tony.kay08:02:30

and SSR doesn't use the bindings either

tony.kay08:02:54

I'd like to write something up in the dev guide, but I'd like to have a use-case where you actually need it

levitanong08:02:20

@tony.kaysorry for the late reply. The most common situation is when you transact! from a view that has been transitioned.

tony.kay17:02:38

Ah, that makes sense...Silly I forgot to test that

tony.kay17:02:44

I'll add that to the demo project