This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-30
Channels
- # babashka (18)
- # beginners (90)
- # calva (33)
- # clara (6)
- # cljfx (11)
- # cljs-dev (22)
- # cljsrn (9)
- # clojure (71)
- # clojure-australia (2)
- # clojure-czech (15)
- # clojure-europe (27)
- # clojure-germany (9)
- # clojure-nl (4)
- # clojure-serbia (3)
- # clojure-uk (10)
- # clojurescript (17)
- # conjure (12)
- # data-oriented-programming (2)
- # deps-new (6)
- # fulcro (29)
- # graphql (10)
- # hugsql (6)
- # jobs (1)
- # lsp (59)
- # malli (8)
- # off-topic (76)
- # pathom (15)
- # polylith (130)
- # re-frame (9)
- # reagent (15)
- # releases (4)
- # rewrite-clj (6)
- # ring (6)
- # rum (9)
- # shadow-cljs (116)
- # specter (5)
- # testing (7)
- # tools-deps (24)
- # vim (6)
- # xtdb (17)
hm, probably i could just add a button that will copy to the clipboard in text format, and anyone could share it here 🙂 if they want
stats for my re-frame project by re-frisk db: 75 | fx: 198 | cofx: 4 | event: 727 | sub: 402 (86)
Hey folks.
I’m using vis.js timeline with re-frame [1].
The timeline has ‘datasets’ that hold items which are displayed in the timeline [2].
The issue is that I need to be able to manipulate these datasets (which are js objects) in different parts of my app.
I’m not sure how to model this with re-frame.
I suppose storing the dataset objects in the app-db
is not a good idea - it looks awkward because the I think db won’t change even if the object does, and it’s not serializable.
So far, I did the following:
- I’m storing the datasets in atoms declared in some namespace
- For manipulating the datasets (add items to it, for example), I created a coeffect that knows about that atom.
- For reading the datasets, I’m not sure what I can do. I’ll probably create some functions that access the atom.
This works and it’s testable (I reset the atoms in each test setup), but I’m wondering if there’s a better way of doing this.
[1]: https://visjs.github.io/vis-timeline/docs/timeline/
[2]: https://visjs.github.io/vis-data/data/dataset.html
If you have to reset an atom to make it store the change, then you can store it in app-db
and it will work fine.
If you can mutate a dataset object, then you don't really need an atom.
You could potentially still store it in app-db
if you update and extract the data only via a small set of functions that you control - then you could wrap the mutable data in an immutable map that has an extra :version
key or something like that that's changed each time you mutate the data.