This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-19
Channels
- # bangalore-clj (35)
- # beginners (42)
- # boot (89)
- # cider (9)
- # clara (2)
- # cljs-dev (29)
- # cljsjs (3)
- # cljsrn (14)
- # clojars (9)
- # clojure (332)
- # clojure-brasil (1)
- # clojure-dev (5)
- # clojure-italy (4)
- # clojure-russia (36)
- # clojure-spec (38)
- # clojure-uk (65)
- # clojurescript (114)
- # clr (11)
- # community-development (105)
- # core-async (10)
- # cursive (4)
- # datascript (1)
- # datomic (58)
- # defnpodcast (3)
- # emacs (4)
- # hoplon (7)
- # juxt (3)
- # keechma (8)
- # off-topic (7)
- # om (109)
- # om-next (8)
- # onyx (26)
- # pedestal (3)
- # planck (8)
- # re-frame (76)
- # reagent (28)
- # rum (25)
- # spacemacs (2)
- # specter (35)
- # untangled (31)
- # yada (27)
The way the debounced function is called is, ahem... a little bit interesting... but that wouldn't be hard to fix I guess
@martinklepsch wouldn't it be more appropriate to use goog.functions.throttle
in this case of search?
If it is called multiple times while it is waiting, it will only perform the action once at the end of the interval, passing the arguments from the last call of the throttling decorator into the decorated function.
https://github.com/google/closure-library/blob/master/closure/goog/functions/functions.js#L377-L380
typing
a
aa
aaa
aaaa
would generate 2 fn calls (assuming everything is typed within single throttle interval):
(f "a")
(f "aaaa")
wait, no.
throttle
would generate just (f "aaaa")
, right?
what would debounce
generate, assuming timeout expires after aaaa
input?
@martinklepsch what are the benefits of mixin over just globally defined debounced function?
misha so in a search input I want to "submit" the last value the user entered after a certain period of inactivity
I do not want to recompute the result at most once every 300ms
at least that's my understanding of throttle vs. debounce @misha
and regarding mixin. The benefit is no global. E.g. what would I do if I have 20 debounced fns? would the all need to be globals?
Hi, does anyone know how to use “decorator” - a high order component with rum? I’m trying to rewrite this https://github.com/danielstocks/react-sortable/blob/master/example/index.js
honzabrecka you can pass components to other components as argument
@honzabrecka the only difference is that in react there's a special children
prop whereas in rum there is not
It’s not possible to use (js/decorator rum-component)
, because rum/defc doesn’t return react class, but some Symbol.
@martinklepsch re debounce: makes sense. re global debounced fns: I found, that having too fat components slows me down, and I decided to keep those as stateless as possible, to be able to clearly separate representation from any logic. This led to "global" debounced functions in my case (those are namespaced anyway, so it's not a tragedy). I still have to find good balance though, because implicitly depending on "global" functions is meh, and passing every single symbol as argument to component is suboptimal too.
Decorator is a React class with render() { return React.createElement(Component); }
under the hood, therefore it fails.
honzabrecka so defc
defines a component constructor
and calling that constructor as a function will actually return the component class
eg (rum-component)
vs rum-component
react-with-addons.inc.js:22480 Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of
Constructor`.`
@honzabrecka an example and an issue on Github would probably go a long way
The only way it works is (:rum/class (meta rum-component))
, but props doesn’t work.
> and calling that constructor as a function will actually return the component class thats actually wrong, it will return the instantiated component class, that is an object
so maybe that rum/class thing is the way to go