This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-31
Channels
- # announcements (16)
- # beginners (52)
- # calva (44)
- # cider (82)
- # clojure (21)
- # clojure-greece (1)
- # clojure-losangeles (1)
- # clojure-spec (8)
- # clojure-uk (3)
- # clojurescript (55)
- # community-development (26)
- # cursive (18)
- # datomic (7)
- # editors (6)
- # events (1)
- # fulcro (19)
- # kaocha (1)
- # klipse (1)
- # off-topic (13)
- # re-frame (1)
- # ring-swagger (2)
- # spacemacs (2)
- # vim (15)
Just learning about AppInventor/Thunkable, which is a whole new world to me, and I see that there's a way to include (I think) arbitrary Javascript: http://thunkableblocks.blogspot.com/2017/08/run-javascript-inside-web-viewer-with.html
@lspector using selfhosted cljs, you can make a reagent component that is a cljs editor for hiccup datastructure that creates another reagent component, which may also be an editor.
I'm not sure if I released anything but I have something of an example of it here https://pepl.io/admin
the above component is rendered by the stuff in the editor below. Then below that are some more examples
to get it to work, I think you'd have to clone my https://github.com/johnmn3/johnmn3 repo and then use your own auth info. But I didn't get around to testing it that far.
@john I'm not sure I see how to take your advice re: my actual question, but https://pepl.io/admin is really cool! I will check that out regardless.
and btw, I think the PEPL idea is pretty awesome, but most of the awesomeness of the inline editor comes from https://www.maria.cloud/
and you want a chrome browser extension that will let you automate browser interactions with clojurescript?
Well I have just the thing for you 😉 https://chrome.google.com/webstore/detail/chrepl/ablpgchfbbfachdiakmieocbdgflgfjj
oh, I think I see what you mean... like, create a blockly language for clojurescript that could fit into that blockly language they're using there to integrate the javascript language
Well, there's always https://github.com/roman01la/jsbin-cljs so if you can fetch a compiled version of that and call jsbin_cljs.core.eval
on the source, you might be able to just do that
I didn't mean creating a new blocky language. I meant using their blocky language and all of the infrastructure they created for it, but to be able to add new blocks that do custom computations, with the code for the new blocks being in Clojurescript (rather than Javascript).
hey - I can’t seem to find how to consume a js iterator from cljs (eg new Map().entries
) - how does this work?
https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L1306-L1312
(def m (js/Map.))
(.set m 0 "kissa")
(.set m 1 "koira")
(def i (.entries m))
(.next i)
(.next i)
What am I missing here?
⇒ clojure -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}}' -m cljs.main -e "(require 'cljs.js) (cljs.js/empty-state)"
Exception in thread "main" clojure.lang.ExceptionInfo: Execution error (Error) at (<cljs repl>:1).
Cannot read property 'empty_state' of undefined
By contrast:
⇒ clojure -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}}' -m cljs.main
ClojureScript 1.10.520
cljs.user=> (require 'cljs.js)
nil
cljs.user=> (cljs.js/empty-state)
#object[cljs.core.Atom {…}]
@U050CT4HR I think it is a race, owing to browser loads being async
Similar ticket: https://dev.clojure.org/jira/browse/CLJS-2663
There is a potential fix in https://dev.clojure.org/jira/browse/CLJS-2854 that I'll re-baseline
what’s the usual way, given an inst, to make a string like 1 minute ago
or 3 months ago
?
convert to ms inst-ms
, then use cond to find something like a duration that matches seconds, minutes, days, hours, whatever
in principle yeah it’s simple but i don’t want to re-invent something that already exists
plus it needs to be human readable so have worry about plurals and stuff
this seems to work in cljs-time
[cljs-time.core :as time-core]
[cljs-time.format :as time-format]
(time-format/unparse-duration (time-core/interval
#inst "2018-03-31T21:43:15.786-00:00"
#inst "2019-03-31T21:43:15.786-00:00"))
Something similar exists in goog
and is probably what cljs-time
uses under the hood.
i've achieved this with moment.js in the past: https://momentjs.com/docs/#/displaying/fromnow/
thanks, however i think i can get something similar from cljs-time
it’s not very well documented
[cljs-time.core :as time-core]
[cljs-time.format :as time-format]
(time-format/unparse-duration (time-core/interval
#inst "2018-03-31T21:43:15.786-00:00"
#inst "2019-03-31T21:43:15.786-00:00"))
and reading the source, this functionality is all built into goog.date.duration
so you can just use that without needing to add cljs-time