Fork me on GitHub
#re-frame
<
2017-01-05
>
andrethehunter07:01:11

Is there any way to check an event has been registered?

martinklepsch07:01:07

@andrethehunter in re-frame.registrar/kind->id->handler you can find all registered handlers

andrethehunter07:01:05

thanks for pointing me in the right direction, re-frame.registrar/get-handler was exactly what I was after

mikethompson07:01:10

@andrethehunter as Martin points out, you can reach into the impl to do a check. But no "offical' API for it ATM

martinklepsch07:01:59

Right, should have added that 😄

limist12:01:27

Advice sought please: Is there a favorite approach or library for animations, for re-frame/reagent? Should one use css animations when possible?

martinklepsch15:01:16

@limist CSS animations when possible, yeah. Didn’t find anything nice for when it gets more complex yet.

martinklepsch15:01:41

@limist there is some stuff in goog.fx but most of it doesn’t add much over CSS animations

limist15:01:21

@martinklepsch OK thanks for the advice! Will let the browser do the work...

martinklepsch15:01:56

@limist what kind of animation are you looking for out of curiosity?

limist15:01:55

@martinklepsch Transitioning new elements (boxes etc) smoothly into the viewport, so they get the user's attention but not in a jarring way. A fade-in, fade-out would also work

martinklepsch15:01:23

That should be possible with ReactCSSTransitionGroup

martinklepsch16:01:00

Yeah, I guess it’s reasonable

mikethompson17:01:26

@limist for enter/leave/move animations we have now switched across to react-flip-move http://www.upgradingdave.com/blog/posts/2016-12-17-permutation.html

mikethompson17:01:50

Which is very easy to use and it is better than ReactCSSTransitionGroup IMO

martinklepsch17:01:45

Oh is that a generic thing? I thought it’s for flipping elements as in the blog post lol

mikethompson17:01:10

It does enter / leave / move annimations (hard to do with CSS annimations)

mikethompson17:01:45

for the elements of a list

mikethompson17:01:01

But, of course, that means you can then get it to handle fade-in and out for panels etc, if you make the panels appear to be elements of a one element list

mikethompson17:01:27

BTW, the FLIP technique is currently state of the art for animations. Such a neat idea and so perfect for React:

mikethompson17:01:21

If you have the time, this YouTube video explains in detail (from memory this is how I learned about it) https://www.youtube.com/watch?v=RCFQu0hK6bU

limist18:01:03

@mikethompson Thanks for the advice and links!

mattly19:01:04

is there any way to access the value of a subscription from inside an event handler without having the subscription passed in via dispatch?

mikethompson22:01:55

@mattly short answer is that you shouldn't Can I ask: do you want to be using the subscription because of the computation it delivers? Or just access?

mattly22:01:05

@mikethompson because of the computation it delivers

mattly22:01:53

it's cool, I'm derefing the subscription in the event handler that calls dispatch

mikethompson22:01:04

Philosophically: subscriptions are designed to deliver "a stream" of new values over time. Within an event handler, we only need a one off value. Operationally: you'll end up with a memory leak.

mikethompson22:01:47

Sounds like you are suppling the value in the event now?

mattly22:01:00

what I'm doing now looks roughly like this:

mattly22:01:44

for various reasons the "chosen" item is derived

mikethompson22:01:01

So you are dispatching the value @chosen-segment with the event ?

mattly22:01:14

the function inside event/prevent-then is called on-click

mikethompson22:01:30

Question: does the subscription handler look like this

(reg-sub 
    :chosen-segment 
    some-fn)

mikethompson22:01:48

OR does it have a signal fn

mattly22:01:58

it has signal functions

mikethompson22:01:32

Hmm. Okay. This is probably something re-frame should do better

mattly22:01:35

somewhat by necessity

mattly22:01:49

I can PM you a private gist if you'd like

mattly22:01:54

or, well, eh, there's nothing special here 😉

mattly22:01:00

my :get-in subscription is what you think it is

mattly22:01:36

I have similar :assoc-in and :update-in event handlers 🎉