Hi. Any improvement tips for my first ever clojurescript code? https://github.com/jayesh-bhoot/enforce-browser-fonts/blob/master/cljs-version/src/ebf/bg.cljs
You could create a higher function where you take as arg state and modification func as 2nd parameter (set and sync)
So modifystaye(state modifystate) modifystate is a func
But is more a style thing imho is good otherwise!
You could use let to improve readability
At line 43
So at least I am on the right track! I have kept the code as it is for now, and will integrate the higher order functions as I learn more.
@jayesh-bhoot imho, what can be improve also, is the (.set
) interoperability with clojurescript
I have not used clojurescript sofar but http://cljs.github.io/api/cljs.core/setBANG
imho in theory you should the .functionNative
when needed and take what is already there
e.g with clojure, .Foo
is most of the time wrapped in a constructor of clojure which read more the clojureway , so it is more avoided then used. It is used when needed mostly 😁
but if you have primitive in clojurescript that does the same thing, i would personally prefer them. hope it helps
Oh I agree. To the point that I was considering using core.aync channel instead of the JS promise mechanism (through promise->chan
and chan->promise
endpoints). May be in the next project.
I think core async is best in clojurescript
Regarding .set
, instead of a simple variable assignment, its an asynchronous set operation, returning a Promise. As in its not exactly a standard JS assignment, but a weird Mozilla API design.
In clojure one could rely also on Java queue
So I couldn't have used the cljs native set!
here
But in Javascript afaik there isnt such primitives that is really cool
So mentally typo:grin:
> I think core async is best in clojurescript I agree. I an already itching to replace my current implementation
A OK thx for clarification about set! Discovered something new
Check this for more clarification - https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserSettings/useDocumentFonts#examples Its an API specific thing. Makes one pull their hair out. 😁