Fork me on GitHub
#clojurescript
<
2019-07-29
>
abdullahibra09:07:57

is clojurescript depending on any browser?

abdullahibra09:07:58

i mean is the js code emitted from clojurescript could be run correctly on specific set of browsers, like chrome and firefox, but not IE or any else?

abdullahibra09:07:13

is google closure compiler target specific set of browsers ?

Roman Liutikov09:07:58

@abdullahibra cljs compiler emits ES3 compatible code

jaihindhreddy09:07:57

^ Is that the case even when we use newer stuff like promises via interop? Does Closure include the relevant polyfills and emit ES3 compatible code in all cases?

Roman Liutikov09:07:57

@jaihindhreddy yes, Closure Compiler will include polyfills

馃憤 4
Roman Liutikov09:07:22

but for that you have to add compiler option :rewrite-polyfills true

danielstockton12:07:31

Is there a way to access build id at compile time, or would I use a closure define?

mfikes21:07:05

Yeah, I would use goog-define for soemthing like that.

Karol W贸jcik17:07:55

Do you know some of the test reporters which work seamlessly in node.js environment with cljs.test?

nenadalm19:07:04

I use doo (https://github.com/bensu/doo) with humane-test-output (https://github.com/pjstadig/humane-test-output). Here is my part of my :test profile in leiningen:

:test
   {:dependencies [[pjstadig/humane-test-output "0.8.3"]]
    :plugins [[org.clojars.nenadalm/lein-doo "0.1.11-SNAPSHOT"]
              [lein-cljsbuild "1.1.7"]]
    :cljsbuild
    {:builds
     {:test
      {:source-paths ["src" "test"]
       :compiler {:main app.run-all
                  :output-to "target/test/app.js"
                  :output-dir "target/test"
                  :target :nodejs
                  :npm-deps {}
                  :optimizations :none
                  :pretty-print true
                  :source-map true
                  :source-map-timestamp true}}}}
    :doo {:build "test"
          :paths {:karma "./node_modules/.bin/karma"}}}}
some npm dependencies:
;; devDependencies
                       [karma "2.0.0"]
                       [karma-cljs-test "0.1.0"]
                       [karma-firefox-launcher "1.1.0"]
beginning of my file running all tests:
(ns app.run-all
  (:require
   [doo.runner :refer-macros [doo-tests]]
   [pjstadig.humane-test-output]
here is reason I use forked version: https://github.com/bensu/doo/pull/176 (maybe karma-reporter improved since then - I don't know)

Karol W贸jcik20:07:22

@U662GKS3F How do you invoke it?

nenadalm05:07:38

I use the leiningen plugin: https://github.com/bensu/doo#plugin I've created 2 aliases in project.clj:

"test" ["with-profile" "test" "doo" "node" "once"]
   "test-watch" ["with-profile" "test" "doo" "node"]
so when I am developing, I invoke it via $ lein test-watch, on ci I use $ lein test

Karol W贸jcik19:07:05

Ups. I don't think it will work with shadow-cljs

nenadalm19:07:36

I've never used that. So I have no idea.

neupsh20:07:51

I guess this is true for all frameworks re-frame/fulcro etc: When do you load the data from the backend? Say I have a main page where there are some navigation links (anchors '<a href=',) or on-click handlers that dispatch reframe events which navigate to the view (through accountant/secretary). The first load of data was during the page load. When and how do I load the data afterwards so that I can populate it in the appdb which will be rendered in the view?

Lu22:07:07

Bare in mind that if you dispatch on-click, you want to be careful because you need to fire the http request even when the user is on the page and simply refreshes 馃槈

neupsh02:07:19

What is the correct way of handling that scenario here?

Lu07:07:46

You could use a reagent form 2 component and dispatch on mount.. and maybe you could wrap it around a when-not data-fetched? to do it just once rather than every single time the component is mounted

Roman Liutikov08:07:49

I鈥檇 say you usually load data when switching to a certain view, so your router have to dispatch an effect that would load data for that view. Because event dispatch is bound to navigation change, this will always work no matter in which way navigation was triggered.

馃憤 4
neupsh13:07:08

@UE35Y835W yes, the when-not data is what I am thinking to do. My main concern in when and how should I dispatch the event to fetch the data. @U0FR82FU1 Yeah this could solve the problem. But this is gonna fetch the data everytime i switch view (say i am in one tab and jump to another tab and back again, it will make 3 calls to backend). Is that normal?

Roman Liutikov14:07:17

@U3MRWH35M This depends on your application. If you load data that could have been changed it鈥檚 better to load it anyway. Doing any kind of smart caching on the client would introduce unnecessary complexity.

馃憤 12
Lu14:07:45

I agree with Roman.. I would take into account: - the rate at which the data changes - is there any expensive computation back-end side? - usefulness of the data you are displaying for the end user

馃憤 4
Roman Liutikov15:07:26

backend should have caching in the first place btw

neupsh15:07:56

Its a firebase application. So the backend is essentially just a data store

neupsh15:07:42

I am new to firebase, but it seems like there is a way where firebase lets me know when the data is updated in the backend.

Roman Liutikov15:07:48

firebase is a real time db, so you do have access to real time updates

Roman Liutikov15:07:36

which means you don鈥檛 have to load data explicitly, just subscribe to collections in the db and push data into application state

馃憤 4
neupsh16:07:43

Thanks @U0FR82FU1 I will try to implement that

lilactown21:07:28

in re-frame, I would use an effect to load the new data from the navigation event

lilactown21:07:55

if you wanted to get fancy, you could pre-empt the click by dispatching a prefetch event + fx to load the data on hover

CyberSapiens9722:07:07

Does anyone know if it鈥檚 possible use the Wordpress front end, (or create themes) I don鈥檛 really know how it works... Integrating with clojurescript?

oconn23:07:22

@cybersapiens97 you can pretty much embed anything in a wordpress site. That said, one thing you may want to be aware of is overall bundle size of your pages.

CyberSapiens9723:07:09

What do you mean by bundle size @oconn

oconn23:07:41

The overall size of your generated JavaScript files.

CyberSapiens9723:07:32

This could possibly mean cljs not being well suited for it? I really wanted to start freelancing Wordpress but using cljs :(

oconn23:07:16

No I wouldn鈥檛 say that at all - with advanced compilation you can get your projects way down in size. The reason I mentioned watching your bundle size is because I鈥檝e seen a bunch of Wordpress sites that suffer from bloat.

oconn23:07:37

If you鈥檙e bolting a CLJS project on top of a bunch of plugins and other frameworks and what not. No problem.