Fork me on GitHub
#re-frame
<
2017-09-21
>
mbertheau09:09:24

What's the current deal with inadvertently returning false from event handlers? Does re-frame handle that for me?

curlyfry09:09:44

@mbertheau In what context would you accidentally return false? In my experience accidentally returning nil is more common. When using reg-event-fx returning nil simply means 'no effects' and works fine.

mbertheau09:09:48

@curlyfry I mean for example an :on-click function

curlyfry09:09:37

:on-click itself isn't really re-frame territory. If you dispatch in your on-click, that's where the re-frame machinery kicks in.

danielneal09:09:57

@mbertheau usually the only thing you will do in on-click is call a reframe dispatch

danielneal09:09:03

and reframe dispatches return nil, so you don't have to worry

vinai10:09:18

I liked being able to return false to stop event propagation to be honest.

lxsameer11:09:30

@mikethompson @danielcompton @daiyi I updated the PR with a link to a build of docs on my local gh-pages, it gives you an idea about how the docs would be https://github.com/Day8/re-frame/pull/414#issuecomment-331123497

nooga14:09:36

I’m trying to figure out a way to css animate element of the list before it gets removed by an event handler and nothing comes to my mind except dispatching an event [:item/hide id] that will change its class and then dispatching another [:item/delete id], say 300ms later by using js/setTimeout. This feels too inelegant. Is there another way?

kasuko15:09:52

I can’t help with the overall elegance of the problem but instead of using js/setTimeout directly just use the :dispatch-later effect

genekim15:09:08

Whoa. @sandbags. That’s… awesome… despite the fact that I totally do not even comprehend any of it… Wow… Haha. My first reaction was, “Wow, cool!” My second reaction was, “What does that do?“. My third reaction was, “No wonder my attempt didn’t work — doesn’t look anything like that.” 🙂 Where do I go learn what :<- is?

kasuko15:09:07

@genekim Best place is in the todomvc example source code docs (weird … I know) https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/subs.cljs#L30

genekim16:09:25

Oooh… Cool… Thank you @kasuko!

nooga19:09:06

thanks @kasuko didn’t know about :dispatch-later

reefersleep20:09:43

@nooga you can use ReactCSSTransitionGroup

reefersleep20:09:45

which, I think, does sort of the same thing, only based on extra lifecyle hooks of react elements

reefersleep20:09:56

(I’ve used it with some success)

reefersleep20:09:30

@nooga my usage is here. Pardon the horrendous code and the usage of create-class, that is because of a different concern which could probably be handled more nicely. But the transitionGroup does work 🙂