This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-25
Channels
- # announcements (22)
- # architecture (6)
- # beginners (76)
- # cider (44)
- # clara (6)
- # clj-kondo (34)
- # cljdoc (4)
- # cljs-dev (8)
- # clojure (162)
- # clojure-brasil (4)
- # clojure-dev (32)
- # clojure-europe (3)
- # clojure-italy (16)
- # clojure-japan (4)
- # clojure-nl (3)
- # clojure-poland (1)
- # clojure-spec (25)
- # clojure-uk (45)
- # clojuredesign-podcast (5)
- # clojurescript (91)
- # clojutre (3)
- # core-async (19)
- # core-logic (8)
- # cursive (60)
- # data-science (3)
- # datomic (7)
- # defnpodcast (2)
- # duct (5)
- # emacs (7)
- # fulcro (1)
- # graalvm (9)
- # graphql (1)
- # jackdaw (12)
- # jobs (1)
- # jobs-discuss (1)
- # kaocha (3)
- # leiningen (3)
- # luminus (2)
- # off-topic (44)
- # onyx (17)
- # pathom (6)
- # planck (15)
- # re-frame (1)
- # reagent (13)
- # rum (2)
- # shadow-cljs (43)
- # spacemacs (3)
- # sql (43)
- # tools-deps (3)
- # vim (43)
- # xtdb (13)
Hello, I'm reevaluating my front-end stack now that I'm a little ways in and familiar with things, curious if anyone has input. Currently I'm scrapping by with re-posh, which is kind of an undermaintained/developed lib that combines posh, datascript, and re-frame to try to expose a "materialized" datascript db. It works, but it's a bit janky and the lack of pull subscriptions is very annoying for my use case. Basically it seems to end up that creating a reactive, logic based system essentially entails implementing a rules engine. ... Which leads me to Precept. Is anyone using it? Does it work/scale well? Is the memory usage a problem? Seems quite interesting, although the lack of parameterized subscriptions is a bit hard for me to wrap my head around. There's also factui, which looks like perhaps the closest to God of all the cljs UI frameworks. But it's unfinished and also plugs into rum (I'm committed to re-com at this point). Is there anything else in this space I'm missing? I'd really love to tap into the awesomeness of datalog for ui, but there doesn't seem to be mature offering yet. Is there a practical way to write reactive views against a datascript db?
I’d say there all of those libraries are not popular because not much people are using them. I like the concept of a DB with a query language in web apps, but unfortunately the more interactive your app becomes the more of a perf bottleneck a DB can become. I don’t have any numbers to bake this, but that’s my general feeling from seeing and hearing how web apps with databases on the client works.
However it might be worth take a look at Fulcro, don’t know for what kind of apps it is suited though.
In JavaScript there’s MobX which offers push-based subscription model, but it has a drawback that state should be described in a form of a model instead of a plain data structure as in Redux/Re-frame etc
Thanks, unfortunately fulcro is doing far too much for my taste, plus I love re-com so much I don't think I wanna move away from ratoms. It's too bad the graph language isn't independent of the rest of the stuff. Hmm, given this is a solo side project I'm tempted to take precept for a spin..
is it possible to store a function name in a map, and get it to call the function (which is in another file)? Something like this:
(defn hello [] "hello")
(def mymap {:id 123 :func 'hello)
((resolve (:func mymap))
generally speaking namespaces will end up mangled beyond recognition when doing advanced compilation, don't know if it's advisable to be smart about that
@romain why not just put the funtion in the map directly? why do you need the name/var indirection?
@thheller I have functions in (ns app.views)
. I also have a generic modal reagent component where attributes are defined in app-state
from (ns app.state)
.
For example:
{:add {:msg "Add modal"
:class "is-primary"
:btn "Confirmer l'ajout"
:func **ADD MODAL FUNC**}
In the modal, I have one button to perform an action. So I must set the button's function and I thought I could store the function to be called in the modal-map in app-state
nice catch thheller, never in 7 (10?) years of clojure did i need to use resolve for regular app dev, that's a code smell
So you mean something like that?
{:add {:msg "Add modal"
:class "is-primary"
:btn "Confirmer l'ajout"
:func app.views/hello}
@romain yes. assuming of course that the ns
this map is created in has a (:require [app.views])
From what I can read, there may be also an issue with resolving and :advanced
compilation. Maybe I should just change the modal's design, but I liked the idea of getting attributes and the action function from my app-state
ie. construct the map in a namespace that can depend on app.state and app.views but is not directly accessed by either of those
Yes I could put that in (ns app.events)
. But as you mention, should I build 2 modals instead of doing this with the risk of resolving?
@thheller it seems better, now I need to fix the error No protocol method IDeref.-deref defined for type undefined:
hm... in my reagent atom, the function is set as :
{... :func #object[app$events$hello]}
Is this what you are doing?
(defn hello [] "hello")
(def mymap {:id 123 :func 'hello})
(resolve '(:func mymap))
What's the problem with this?
(defn hello [] "hello")
(def mymap {:id 123 :func hello})
((:func mymap))
in my (ns app.state)
I have
(ns app.state
(:require [reagent.core :refer [atom]]
[app.events]))
(defonce app-state (atom {:modal {:add {:msg "Add modal"
:class "is-primary"
:btn "Confirm"
:func app.events/add-modal}}}))
And in my (ns app.views)
[:a.button {:type "button"
:on-click (:func (:add (:modal @app-state)))}
"Confirm"]]]]]]]]))
you are forgetting that #
to your on-click
function.. you need to pass an anonymous function
Oh I see you're not calling a function in there so it's fine.. what's app.events/add-modal
?
I forgot in the snippet above, I also pass app-state
to add-modal
(defn add-modal [db]
(do
(add-request (:add-email @db)) ;; Perform a POST request and update db (app-state)
(toggle-modal db ""))) ;; just a function to set class to "" to close the modal
[:a.button {:type "button"
:on-click #((-> @app-state :modal :add :func) app-state)}
"Confirm"]
I just tried it. I don't have the error anymore, but I have another one Error: No protocol method ISwap.-swap! defined for type undefined:
. The swap is done in another function called in :finally
request, but I think I can debug that 🙂
@lucio I confirm, it works well now... I thought a modal will be cool and simple, finally it adds a lot of complexity and code 😄
Anyone have any experience using React context with Rum?
Is there any reason to use core.async when using re-frame?
is anybody using this? https://www.npmjs.com/package/react-chartjs-2
Uncaught Error: Undefined nameToPath for react_chartjs_2
at visitNode (base.js:1357)
at Object.goog.writeScripts_ (base.js:1369)
at Object.goog.require [as require_figwheel_backup_] (base.js:706)
at figwheel$client$file_reloading$figwheel_require (file_reloading.js:576)
at figwheel$client$file_reloading$require_with_callback (file_reloading.js:1154)
at figwheel$client$file_reloading$js_reload (file_reloading.js:1204)
at figwheel$client$file_reloading$reload_js_file (file_reloading.js:1213)
at file_reloading.js:1290
at file_reloading.js:1360
at figwheel$client$file_reloading$load_all_js_files_$_state_machine__31867__auto____1 (file_reloading.js:1381)
this is my relevant project.clj
section:
:npm-deps {:react-chartjs-2 "2.7.6"
:chart.js "2.5.0"}
:install-deps true
looks like someone else had this issue (no answers on stackoverflow): https://stackoverflow.com/questions/55341643/undefined-nametopath-when-using-clojurescripts-npm-deps
@johanatan :npm-deps
is not recommended unless you're using Node.js
it's an alpha feature and getting all the various libraries to work is unlikley in the near future
well, there happens to be a cljsjs for this one. would that be ok too? https://github.com/cljsjs/packages/tree/master/react-chartjs-2
is the longer term vision for these that they would work tho? what are some of the hurdles to making that happen? i could potentially help out ...
unless you're ready sink 3-6 months of full time work - I'd put your energies elsewhere
@dnolen where are the effort concentrated on cljs at the moment?