This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws-lambda (7)
- # beginners (113)
- # boot (17)
- # cider (4)
- # cljs-dev (4)
- # clojure (65)
- # clojure-greece (3)
- # clojure-italy (7)
- # clojure-russia (10)
- # clojure-spec (37)
- # clojure-uk (20)
- # clojurescript (76)
- # community-development (2)
- # cursive (24)
- # data-science (9)
- # datomic (9)
- # emacs (1)
- # fulcro (2)
- # graphql (11)
- # hoplon (13)
- # juxt (15)
- # leiningen (1)
- # off-topic (36)
- # om (1)
- # onyx (59)
- # parinfer (41)
- # pedestal (7)
- # portkey (60)
- # protorepl (4)
- # re-frame (345)
- # reagent (7)
- # ring-swagger (16)
- # shadow-cljs (121)
- # spacemacs (30)
- # sql (6)
- # uncomplicate (2)
- # unrepl (9)
- # vim (13)
- # yada (2)
hello wonderful people, I'm looking for direction on how best to use a set of popup for data presentation (not ads, this is an internal tool, clojure/clojurescript/om)
@U06GS6P1N I just don't know where to start I think I am googling for the wrong terms.
@U7AHRRSS2 it's difficult to help without knowing what you already know how to do. Do you already have an Om app to add this functionality to? Do you know web development (in CLJS)? Are you wondering how to layout a poput in terms of HTML / CSS?
In case that's the last one, I would have a look at bootstrap modal: http://getbootstrap.com/docs/4.0/components/modal/
Hi everyone! I was trying to convert some strings into numeric literals and got some unexpected behaviour. Can someone explain this?
(read-string "07") => 7 (read-string "08") NumberFormatException Invalid number: 08 clojure.lang.LispReader.readNumber (LispReader.java:330) (read-string "09") NumberFormatException Invalid number: 09 clojure.lang.LispReader.readNumber (LispReader.java:330) (read-string "10") => 10
I'm still looking for assistance in getting a data popup sorted out. Basically, in om I need to have a button that launches a popup modal with close button with scroll that pretty prints a PersistentMap.
or, really, you should require cljs.pprint and give it a shorter name in any ns that uses it
but it still isn't launching the alert. But I'm not even sure that this is the correct way to do it as the PersistentMap is quite large.
I'm a bit stuck here. I need to take a default value a sequence of keys and return a map with the default value set to each key.
changing the value if the key is already there, or only updating with thedefault if not present?
anatpaatra, can you write out a small example of input and output and what the defaults are?
so you need to make a map out of a vector of keys and a single value, where each key in the vector has the single value you give it?
hey @noisesmith, past few days you helped me a lot with the tip of using component to startup my system and stateful resources. one thing that I’m struggling to accomplish is that sentence > the idea is most of your functions stay pure, based only on arguments … how usually you accomplish that ? for instance, I have one endpoint ( using your idea of middleware to inject the database and other components I need ) that will validate against database and call one external service ( aws cognito ) . how you divide/organize your function to keep most pure as possible ?
I am reading SICP right now, to get a better understanding of functional design
@oliv the big picture answer is that the component/start function runs all your initializers (connecting to dbs, opening ports, opening files, all that) and the function that does that is the impure one - it takes a map with other components plus config and returns a "started component"
the other components, plus your main app code, use the hash-map of started components returned by the component/start call to do all the things that need those resources
of course you need pure and impure elements in real code - the trick is to make sure that you aren't pretending something is pure that leaks impurity underneath - the component architecture helps you do that by explicitly segregating startup from functionality
yeah, I see ! my “service” layer is a mixed of pure + impure ( database + service calls … )
@oliv right, it's less about purity at that point, and more about making sure all the inputs to your function are given via arguments. That also makes it easier to test, want a temp DB? Just pass in a different arg.
yeah @tbaldridge exactly . my compromise right now is to receive everything that I need from arguments ( using component help me a lot )
want a hash-map in memory instead of a document store when testing? if you wrote your component right, you can do that by providing a different arg on system startup
Make sure though that each function takes only the components it needs. If you hand everything to every function there's a temptation to introduce tight coupling where everything needs everything in order to do anything.
you don't have to split out the parts of the component, just write the components so you don't pass in things it doesn't need
yeah - the tight coupling around the component can be a problem for sure - it seems like someone is always trying to grab the global component reference and use that instead of using what's passed in, or write things that expect every single component to be available and visible
the system has all the components, but under each component's entry are the components it needs. so it's as simple as not passing the system to each function, but the component
yeah, better receive as arguments the components than use the system inside the function
Is a function that receives another function as an argument and invokes it considered pure if the function given to it is impure?
@lvbarbosa for the purpose I care about foo is pure - I can test it without mocking what bar does or creating an environment where it's safe to run bar in a test
if foo isn't pure, map isn't pure, filter isn't pure, etc. - which most of us would find an odd definition of purity
So I am not spreading impureness throughout my system if I start up some components (e.g. connection pools) and pass them around?
it's containing impurity, because the other choice is to write code that directly accesses the impure capabilities via global references
I wish "impurity" had a different name, because my desire for it as a software developer isn't about some sort of puritanical rejection of side effects, it is that if I contain impure things and use them as parameterizations of my code rather than building blocks, I can easily test and reason about the logic
so, the rule of thumbs is: avoid global references, always only use what you receive as arguments, right ?
and in a good clojure codebase almost everything should be constant (modulo repl mechanics)
i wonder, are dynamic vars considered bad in clojure, since technically they break referential transparency?
they seem used exactly how you would in common lisp, which is incredibly useful, yet it's clearly against the hard-line haskell position
nothing is ever outright bad, it's a matter of using features only when they are the best alternative and/or make sense. pragmatism in other words
referential transparency is a very good property to be strived for, but not at any cost
That's good news. I've found a few dynamic vars in libraries exactly where I wanted them too, which has been really refreshing in a JVM setting 🙂
From RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", Section 4.2, "Message Headers": > Each header field consists of a name followed by a colon (":") and the field value. Field names are case-insensitive.
I thought that standard Ring middleware for headers converted them to Sentence-Case before returning them, but
I may be wrong that is not the case. I know that the middleware converts them all to lowercase to make them, essentially, case insensitive (and it specifically uses
.equalsIgnoreCase to ensure case insensitivity).
Ah, per the Ring Spec: https://github.com/ring-clojure/ring/blob/7b1657128991e483232cd1ee3b87d2cc481e269c/SPEC#L98 they are deliberately downcased.
^ @rcustodio So, yes, it's normal to use lowercase -- because the Ring Spec says headers should be downcased prior to passing the Ring Request to a handler -- and they are not case sensitive so it doesn't matter whether you use