Fork me on GitHub
#clojurescript
<
2017-12-27
>
fabrao00:12:37

Hello all, is there any way to use chart javascript/clojurescript from java without having browser?

fabrao00:12:18

I want to use http://canvasjs.com charting to generate report, but it has to run in schedule mode, so no browser

vemv04:12:35

cljs pdf generation https://www.youtube.com/watch?v=X6rxaDtZMPg (don't recall the exact approach described in the vid... but it'll take you 5min to find out ;p)

avivak09:12:21

I try to use re-frame together with reagent. In the initialization of the page I need to make two ajax calls. so, the initialization event has to return two :ajax effects - here is the code:

(reg-event-fx
  :init-db
  (fn [coef event]
    {:backend-ajax {:method :get, :url "/rest/items",:on-success [:set-items] :on-failure [:comm-err]}
     :backend-ajax  {:method :get, :url "/rest/settings", :on-success [:set-settings] :on-failure [:comm-err]}}))
of course, I cannot put the same key twice, but how to return two effects of the same type with different parameters?

mikethompson09:12:20

@avivak First, there's a re-frame channel which would be a better place for this question Second, you might be interested in reviewing re-frame-http-fx or perhaps (more powerful, but more complicated) re-frame-async-flow Third, and now I really am getting around to answering your question, you, the writer of the effect :backend-ajax, can allow for a vector of maps to be supplied if you want. You get to design the :backend-ajax DSL any way you want, provided you then interpret it in your effect handler (I'm assuming it is your effect and not something from a library)

carkh09:12:20

this re-frame-async-flow thing looks nice

avivak09:12:32

@mikethompson Thanks for your answer! 1. I'll move to re-frame channel. 2. just for your answer. the :backend-ajax was written by me. but I wanted to keep the implementation of the effect as simple as possible (handle just one request). I thought it might be supported by re-frame. the re-frame-async-flow handle actions flow, I need them to be executed in parallel.

mikethompson09:12:52

@avivak re-frame-http-fx handles multiple (via a list or vector of maps)

Macroz11:12:09

Are there any tools for analyzing the output of Closure to see what dependency takes what space after optimization?

qqq11:12:22

@macroz: that sounds useful; if you find something, can you DM me the library name?

Macroz12:12:06

just asking because these kinds of tools exist for the webpack ecosystem i.e. https://github.com/webpack-contrib/webpack-bundle-analyzer

thheller12:12:22

@macroz I built something recently. not much on the visual front but the table provides all the info you’d need. https://clojureverse.org/t/help-wanted-release-bundle-size-visualization/871/9?u=thheller

Macroz12:12:46

Looks cool! How does it work? Does it compile/zip each file separately or the whole bundle together?

thheller12:12:58

it takes the optimized output file + source map and uses the source map to get fairly accurate sizes how many bytes belong to each individual source file

thheller12:12:22

gzip is done for the overall file but not separately since that would not be accurate

Macroz12:12:29

gzipped size of a file is a fraction of the whole gzip size?

thheller12:12:16

might be a bit too inaccurate but could be done yeah

thheller12:12:04

I didn’t spend too much time on this yet. I only wanted to rough overview and something I can track over time.

thheller12:12:20

lots of improvements could be done for sure

Macroz12:12:42

:thumbsup: this is the kind of tooling I meant

Macroz12:12:42

found someone made this for the purpose https://github.com/stephanos/minifyretracer

Macroz13:12:49

this sort of worked but most of the code is in unmapped https://github.com/danvk/source-map-explorer

Macroz13:12:38

hmm probably because it is NPM (React) modules

Macroz13:12:57

all cljs code seems to be nicely mapped

Macroz13:12:10

would need to have the tooling combine the source maps of JS deps with the CLJS maps

djebbz14:12:45

Hello everyone, is there a way to delete the property of a JS Object in CLJS ? Or unset! it ? In my tests I need to set the global error handler window.onerror but I want to clean up after

djebbz14:12:07

I'm currently using (set! (.-onerror js/window) nil) since it's null by default, but I'm wondering if there's a better way

djebbz14:12:44

Thanks @macroz, didn't know it existed ! But I've just realized I don't really want to js-delete window.onerror, it should exist after my test. Not sure about the consequence of completely deleting it (messing with window properties might introduce some weird bugs down the road)

djebbz14:12:41

deleting it means it'll be undefined in the browser, whereas setting it to nil means it's null in the browser. May not be a problem...

Macroz14:12:46

maybe you would want to addEventListener and removeEventListener?

djebbz14:12:36

Indeed normal eventListener API... How could I forget ? Thank you !

djebbz14:12:17

messing with onerror manually is a bad idea in a testing framework... (`Karma` through doo)

sova-soars-the-sora19:12:50

hello everyone. happy commencement of post solstice gradual day lengthening. one of my rum :input#search-inputs changes the value of the atom :on-change with #(reset! ... ) and i'd like to also run another function at the same time as :on-change that runs a database query

sova-soars-the-sora19:12:10

is there a simple way to do this? put a watch on the atom and have thngs happen on watch? (have not done that yet)

noisesmith19:12:34

@sova are you using reagent?

noisesmith19:12:26

if not, add-watch is quite straightforward to use, but reagent has something called reactions that are designed for this sort of thing

sova-soars-the-sora20:12:03

@noisesmith using rum, which has > reactives

sova-soars-the-sora20:12:19

< rum/reactive but i'm not sure how it does what it do

sova-soars-the-sora20:12:22

my main question is, can i ttry to cram 2 function calls where 1 anonymous function fits nicely in my :on-change section

sova-soars-the-sora20:12:39

or does it make more sense and add more clarity to figure out how to make a separately exisiting atom watcha

noisesmith20:12:58

can’t you make an anonymous function that does two things?

noisesmith20:12:09

perhaps I am missing something obvious here

sova-soars-the-sora20:12:49

haha you definitely can, but i'm a newbie and question the obvious at every turn 😄

sova-soars-the-sora20:12:33

can one wrap multiple function calls with (do ) ... inside an anonymous call?

noisesmith20:12:45

it seems like the simple thing is to just make a real anonymous function

noisesmith20:12:58

#() is a shorthand for (fn []) and fn has an implicit do

sova-soars-the-sora20:12:34

so #( something % ) is the same as (fn [x] (something x)) ?

noisesmith20:12:57

=> '#(+ % %2)
(fn* [p1__47179# p2__47180#] (+ p1__47179# p2__47180#))
substituting for weird names that expands to (fn [x y] (+ x y))

sova-soars-the-sora20:12:21

thanks for figuring out my question for me too haha

sova-soars-the-sora20:12:52

hey i have another questoin

sova-soars-the-sora20:12:03

while i have some clarity to phrase it right

sova-soars-the-sora20:12:15

i'm going to let people do the kind of search where results are instant

sova-soars-the-sora20:12:31

so i need to figure out a way to do it smarter than google, and locally cache results for every new word

sova-soars-the-sora20:12:45

typing in "hidden" to search you'd effectively be searching for:

sova-soars-the-sora20:12:50

h, hi, hid, hidd, hidde, hidden

sova-soars-the-sora20:12:13

later if you ask for "hid" you wouldn't need to send as detailed a list back [just changes/deltas/updates] ...

sova-soars-the-sora20:12:31

since it's still kinda brainstorming mode, do you have any thoughts on this fun puzzle?

noisesmith20:12:27

there’s an example that dnolen put together for this, the short version is “debouncing”

sova-soars-the-sora20:12:05

wow really?! i am ecstatic to hear that stronger minds have already come across it xD

noisesmith20:12:17

maybe I misunderstood your question actually… but usually debouncing is called for when using an API to back an auto-filled completion (sounds like maybe you need caching too)

sova-soars-the-sora20:12:41

Totally different question. Although that's a great idea, I actually want non bounced input

sova-soars-the-sora20:12:21

but i'll consider it more, maybe it makes no sense to cache hi and hid and hidd if all you want is hidden

noisesmith20:12:59

this being clojure, that cache is very easy to create and manage - it can just be a hash-map with string keys in an atom

noisesmith20:12:14

(as long as you don’t need something super fancy from it at least)

sova-soars-the-sora20:12:40

yeah i really don't need much fanciness. just some sort of append-only cache. although i am looking to datascript because the client-side db might get large enough quickly enough to warrant some more query flexibility

lilactown21:12:57

so is devcards basically react-storybook for cljs?

Jimmy Miller04:12:08

They are aimed at slightly different use cases, but definitely similar.