This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-05
Channels
- # aleph (90)
- # announcements (4)
- # aws (2)
- # beginners (61)
- # calva (2)
- # cljs-dev (8)
- # cljsrn (12)
- # clojars (4)
- # clojure (42)
- # clojure-europe (1)
- # clojure-finland (1)
- # clojure-greece (2)
- # clojure-houston (1)
- # clojure-italy (3)
- # clojure-nl (30)
- # clojure-spec (41)
- # clojure-uk (87)
- # clojurescript (44)
- # cursive (12)
- # data-science (11)
- # datomic (24)
- # defnpodcast (1)
- # fulcro (18)
- # hyperfiddle (1)
- # jobs (2)
- # juxt (11)
- # kaocha (3)
- # london-clojurians (5)
- # mount (2)
- # nrepl (2)
- # off-topic (9)
- # onyx (25)
- # other-languages (1)
- # parinfer (3)
- # pathom (5)
- # pedestal (3)
- # portkey (1)
- # re-frame (21)
- # reagent (24)
- # remote-jobs (7)
- # schema (2)
- # shadow-cljs (59)
- # spacemacs (5)
- # specter (7)
- # sql (9)
- # tools-deps (13)
@clardata6249 have been going through it recently with a friend who is learning and it still feels quite relevant
Hello I am trying to integrate reagent snippets using klipse in an reagent application. But I am having an issue. I get this error when I try to load Reagent. `Execution error. ERROR: Error: No protocol method ISwap.-swap! defined for type cljs.core/Atom: [object Object]`. Help anyone? Here is what html file looks like
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/css/styles.css" rel="stylesheet" type="text/css">
<link rel="icon" href="/img/favicon.ico">
<title>Klipse Reagent Demo</title>
<link rel="stylesheet" type="text/css" href="">
<script>
window.klipse_settings = {
selector: '.language-klipse',
selector_reagent: '.language-reagent',
}
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="app"></div>
<script src="/js/main.js" type="text/javascript"></script>
<script src=""></script>
</body>
</html>
reagent entry file
(ns app.core
(:require [reagent.core :as r]
[re-frame.core :as rf]
[app.db]
[app.views :refer [app]]
[app.services]))
(defn ^:dev/after-load start
[]
(rf/dispatch-sync [:initialize-db])
(r/render [app]
(.getElementById js/document "app")))
(defn ^:export init
[]
(start))
views
(ns app.views
(:require [re-frame.core :as rf]))
(defn cljs-code [code]
[:pre
[:code {:class "language-klipse"} code]])
;
(defn reagent-code [code]
[:pre
[:code {:class "language-reagent"} code]])
(defn app
[]
[:div
[cljs-code "(require '[reagent.core :as r])"]
[reagent-code "(defn app [] [:div 'hello world'])"]
[:h1 "Re-frame application"]
[:button {:on-click #(rf/dispatch [:add-product-to-freezer {:name :vanilla
:amount 20}])}
"Add"]])
using criterium I've narrowed down my issue to calling (apply merge data)
where data is a sequence of maps
so I have data in this format: ({11266661 {:shipment-dispatch 0, :stock-adjustment 0, :receipt 0}} {11185294 {:shipment-dispatch 0, :stock-adjustment 0, :receipt 0}} {11664105 {:shipment-dispatch 0, :stock-adjustment 0, :receipt 0}}...
<- lazy sequence
and I need it in this format: {11266661 {:shipment-dispatch 0, :stock-adjustment 0, :receipt 0}, 11185294 {:shipment-dispatch 0, :stock-adjustment 0, :receipt 0}, 11664105 {:shipment-dispatch 0, :stock-adjustment 0, :receipt 0}}
<- realized map
is there a way to achieve this using (loop)
or some other less functional means as it seems that this is where performance is crippling me
@foamdino have you considered using Reducers? kinda looks like it's appropriate situation for them
@alisher.atantayev is there a standard idiom for converting from (apply merge ...) to a reducer?
@foamdino I've just tried a version with reducers - it's actually slower than just (apply merge data)
FWIW we have parts in our code where we drop back to mutable Java HashMaps for performance reasons when dealing with “very large” data
Btw, speaking of large data - has anyone used cheshire
to lazy load json content in a particular nested node? For example, I have json like {"package": "354", "misc-info": {..}, "entries": [{...lots of data...}]}
and I need to lazy-parse precisely the "entries"
part of json file. I'm not sure cheshire's parsed-seq
is suitable here. Is there a way to achieve that?
@alisher.atantayev Interesting. I’ve mentioned this case once in the #ring-swagger channel where I asked if maybe jsonista could support this (cc @ikitommi). I haven’t tried this myself yet.
how to map a vector of keywords to add a string to them? [ :a :b :c] => [::ns/a ::ns/b ::ns/c]
I don't think either of the above actually get expanded to namespaced symbols (which is what I assume is wanted here)
(require '[clojure.string :as string])
(keyword ":string" "foo") ;; => ::string/foo
(= ::string/foo (keyword ":string" "foo")) ;; => false
Hello, is there a native function to get values of a large lazy seq between a start and end param ? Something like (nth-range 1 2 [“a”, “b” “c”])
Hey guys, is there still a cursive channel? Got a (probably silly) formatting question.
@dpsutton thanks!