This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-07
Channels
- # admin-announcements (2)
- # boot (111)
- # capetown (5)
- # cider (15)
- # clara (15)
- # cljs-dev (8)
- # clojure (78)
- # clojure-brasil (1)
- # clojure-dev (2)
- # clojure-greece (25)
- # clojure-hk (1)
- # clojure-russia (5)
- # clojure-seattle (1)
- # clojure-spec (120)
- # clojure-sweden (3)
- # clojure-uk (63)
- # clojurescript (161)
- # data-science (1)
- # datomic (21)
- # editors (43)
- # emacs (3)
- # funcool (1)
- # hoplon (72)
- # instaparse (11)
- # jobs (1)
- # off-topic (2)
- # om (212)
- # onyx (9)
- # other-languages (129)
- # proton (5)
- # re-frame (15)
- # reagent (18)
- # slack-help (4)
- # spacemacs (18)
- # untangled (224)
- # yada (21)
does anyone have a good strategy for showing a temporary event message? i.e. user clicks “save” — show it for a few seconds then make it go away.
the easiest is probably a settimeout and dispatch again shortly thereafter, but this seems icky, and probably better done through middleware
@lwhorton: re-frame is event based. Very dispatch
oriented. The app doesn't move forward unless an event happens. So the original putting up of the message will happen because of a dispatch
and the taking down of the message should also happen because of a dispatch
.
So, in the handler which puts the message "up", also organize to take it down via something like
(js/setTimeout #(dispatch [:take-it-down]) 2000)
Can't see much way around it
With the new Effectful event handlers it will becomes a bit cleaner
But it will be the same general principle
-------------- Alternatively, could CSS help here?
Show the message, but give it the necessary CSS so that animates to invisible/transparent after 2 seconds.
That way you never have to take the message down.
I considered that, too.. and also a react transition group - but i dont quite yet want to get into trying to animate things in reframe.
I ended up with a custom middleware (cause i sense this is going to happen often) that takes care of the set-timeout removal so my handlers are cleaner.
@lwhorton: IMHO: that's not "application state", it's just "ephemeral" state not worth keeping on your app-db. I'd probably use setTimeout to change a simple local ratom (all local to your component)
can't wait for effectful handlers, my idea was to implement them exactly with a timeout that executes the "registered" functions for effectful events
and dispatches the effectful function's generated events