This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-20
Channels
- # adventofcode (8)
- # aleph (2)
- # announcements (10)
- # aws (5)
- # aws-lambda (2)
- # babashka (23)
- # beginners (23)
- # biff (9)
- # calva (4)
- # cider (8)
- # clj-kondo (21)
- # clojure (77)
- # clojure-boston (1)
- # clojure-dev (50)
- # clojure-europe (36)
- # clojure-gamedev (3)
- # clojure-nl (1)
- # clojure-norway (3)
- # clojure-spec (33)
- # clojure-uk (3)
- # clojurescript (22)
- # core-async (3)
- # cursive (10)
- # datahike (18)
- # datalevin (1)
- # datascript (9)
- # deps-new (21)
- # emacs (11)
- # events (1)
- # graphql (11)
- # guix (26)
- # java (7)
- # jobs (3)
- # lsp (12)
- # malli (6)
- # pathom (33)
- # pedestal (3)
- # polylith (15)
- # reagent (5)
- # releases (3)
- # remote-jobs (1)
- # scittle (9)
- # sql (27)
- # tools-build (9)
- # vim (7)
I'm using reagent for a small app. I'd like to persist parts of the "html" / hiccup in the database, since it may change. But I have no idea, how to persist it to a dabase and get it back rendered as valid hiccup. Do you see a way, how to persist "layouted text" in the database?
are you using re-frame? just out of curiousity
@USDPTD3FY currently looking into it. looks very interesting, makes fun reading documentation, this one catched me:
Sure, right now, you're thinking "lazy sod - make a proper Computer Science-y diagram". But, no. Joe Armstrong says "don't break the laws of physics" - I'm sure you've seen the videos - and if he says to do something, you do it (unless Rich Hickey disagrees, and says to do something else).
Reframe is nice 🙂. but since you aren't using it don't feel pressured to dive into it right now
The reason I ask is that re-frame's philosophy is that rendered views i.e. hiccup should always be derived from data, and that the data should flow into the view functions and not the other way around
so storing layouted text in the db would be against the recommendations of that particular tool
but as you are not using re-frame, there is no need to obey this
Oh, I dont feel pressure. It's really fun for me playing around in that domain and exploring all that stuff!
then, this is a simple approach: you can pr-str the atom into local storage, and edn/read-string it back into data.
@U051GFP2V yes it does! Im gonna give that one a try.
here’s a more complicated approach: https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/local-storage
not to pile on but this should help too: https://gist.github.com/daveliepmann/cf923140702c8b1de301
keys and values have to be strings — I’d writ it like this with the string encoding/decoding
(ns localstorage
(:require [clojure.edn :as edn]))
(defn set-item!
"Set `key' in browser's localStorage to `val`."
[key val]
(.setItem (.-localStorage js/window) (pr-str key) (pr-str val)))
(defn get-item
"Returns value of `key' from browser's localStorage."
[key]
(edn/read-string (.getItem (.-localStorage js/window) (pr-str key))))
(defn remove-item!
"Remove the browser's localStorage value for the given `key`"
[key]
(.removeItem (.-localStorage js/window) (edn/read-string key)))
I need to check if a context is true, and the way I know how to do it is through the clojure.core/match function, but I don't need any action, I just want to know if the context fits my conditions. I'm doing something like:
(defn fit-context? [event-name input]
(match [event-name input]
[: ({:context {:context/reason (_ :guard is-bla?)}
:person {:type :nice-person}}
:guard [not-that?
and-that?])]
true
:else false))
how could i do the same, without needing to explicitly return true
or false
I was adding unnecessary complexity for something very simple rsrs
I use the and
function for that