This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-27
Channels
- # admin-announcements (1)
- # aleph (3)
- # beginners (72)
- # boot (67)
- # braveandtrue (1)
- # cider (17)
- # cljs-dev (8)
- # cljsfiddle (2)
- # cljsjs (1)
- # cljsrn (2)
- # clojure (19)
- # clojure-greece (1)
- # clojure-russia (42)
- # clojurescript (15)
- # core-logic (10)
- # cursive (6)
- # datomic (2)
- # hoplon (349)
- # kosmos (3)
- # lein-figwheel (3)
- # om (52)
- # onyx (3)
- # overtone (1)
- # parinfer (11)
- # proton (11)
- # protorepl (3)
- # reagent (29)
- # ring-swagger (2)
- # spacemacs (1)
- # testing (3)
- # uncomplicate (1)
so, if I create a new local storage cell like this:
(def stored-cell (local-storage default-cell ::my-cell))
what’s the best way to reset that to the default value of my-cell
?
is (reset! stored-cell default-cell)
enough, or will that cause problems with the local storage handling?
soz, (reset! stored-cell @default-cell)
is there any special behaviour for storage cells?
i’m thinking of doing a writeup on it
@levitanong: it would be nice to get the basic usage of hoplon documented too, so when people become curious they have a smooth “on ramp”
@thedavidmeister: Isn’t README.md sufficient?
i would say no, because there are many useful functions and macros and techniques provided by hoplon core that are not documented in either README or the wiki
and because i see a lot of very similar questions being asked in this chat each week
and even though a lot of this stuff might exist as part of one of the demos in the demo repository, many people won’t find/understand it in that format
I see! Okay, I’m game to do it. If you could list down those common questions, that would be great so I could structure it better.
i’m just going to be casually putting stuff up on the hoplon repo as issues
everything related to performance is a big one
I only just realised that the DOM is built statically and then do!
assigns watchers for cells recently
if you don’t know that, and you don’t know about javelin propagating values, I can see how all the performance stuff is confusing
and i’m sure i’m only just scratching the surface with that 😉
yup, and that will prolly dovetail nicely into best practices also
also, storage cells, for which there are quite a few different backends for, aren’t documented afaics ^^
and smaller things
with-timeout
, detecting page load, how to use the route-cell
, etc...
@levitanong: i put up a couple of issues for some docs, feel free to have a crack at it
@thedavidmeister: one thing about the storage atom that was recently(ish) added is the :ignore-existing
keyword arg
normally the storage atom will initialize itself with the value stored in local storage
but sometimes you want to ignore what's in local storage and start with whatever is in the cell you're wrapping instead
@micha: ah cool, i’ll paste that explanation onto the issue and write up later
@micha: what about an explanation on how to implement your own storage backend?
a storage backend is basically a js object that has .getItem(key)
and .setItem(key, value)
methods
(function() {
var firebaseStorage = {
getItem: function(key) {...},
setItem: function(key, value) {...}
};
window.firebaseStorage = firebaseStorage;
})()
(defn firebase-storage
[atom k & {:keys [ignore-existing]}]
(html-storage atom js/firebaseStorage k :ignore-existing ignore-existing))
@thedavidmeister: thanks for the issues! Will work on it as soon as I can
@micha: ah ok, so that bit is usually done in raw JS and then just wrapped up for hoplon?
do you know an example of that I can review?
(defrecord FirebaseStorage [key]
hoplon.storage-atom.IStorageBackend
(-get [this not-found] ...)
(-commit! [this value] ...))
(defn firebase-storage
[atom k & {:keys [ignore-existing]}]
(hoplon.storage-atom/store atom (FirebaseStorage. k) :ignore-existing ignore-existing))
ok cool
thanks
well, i think it’s a nice easy way to save stuff
it would be interesting to make a single page app with lots of content and see how google really indexes it
webmaster tools seemed to show it working OK for me
although i do have pre-render on
but, how would they know about “pages” that are just created from URL fragments
like with a SPA the page is actually finished loading at some time after the html and js are downloaded
there is no universally established way for an application to signal that the DOM is built
i specifically added some stuff to the page after window load
so that’s a good point
shifting the responsibility for rendering the js to the server rather than to google's crawler
maybe they just don’t crawl you if you’re too slow 😛
well i know they don’t like slow pages
yeah, i’m using cloudflare
which is easy enough to setup
because people with the best content are not so concerned with page load times, since they don't have a high bounce rate
ah, but it’s all mobile first, etc.
so i think part of the argument is that page speed is “part of the content"
well, part of the quality of the content anyway
if you're like facebook or something that people just flip to when they're bored then yes
but the best content is not something people will flip to for 0.2 seconds and then click on something else with their ADD
depends where you live
i’m sure if you’re in america it’s all fine
but many sites i go to can take a long time to load
all that latency to american servers
will be nice when everyone is doing http2
fewer roundtrips will be a great thing
that has been nice
yeah, i’ve been playing around with that
it’s been good
one more reason to use hoplon
actually, that’s probably worth mentioning on the performance writeup
i was looking at electron
to see how hard it would be to setup hoplon in that
and have an offline version
uh, i think there’s some node in it
but from what i read it’s basically just index.html
wrapped up in an app
with a few node functions to bootstrap the right bits
i was thinking of having different storage backends depending on whether it’s online or offline
but pretty much everything else working the same
i was thinking fully offline
so when it comes back online you have to reconcile its state with all the things that happened in the rest of the world while it was offline
like, you could use it as an app
i’m cool with a “save” button
but you still have the issue of like two versions of the app are being used by the user
yeah, i’m trying to minimise direct user interaction
yeah, i’ve got a few options
i’m not at that point yet
that’s a problem for future me
right now, i’m still just experimenting with solving different problems in hoplon
and refactoring everything i do every week or so, lol
anyway, i gotta cruise
it’s late here
later @thedavidmeister !
AWYIS
it’s not live live. but the dev version is on the interwebs. isn’t there some way to tell google about a new website so it can scan?
hey @micha, is it really necessary for hoplon to redefine certain methods like insertBefore?
I ask this because it seems to be interfering with some of d3.js’s behaviors
when not using hoplon, when d3 creates and inserts an element, the newly created element has parentNode defined. when using hoplon and d3 creates and inserts an element, it’s null.
(ul
(li "this is static")
(loop-tpl :bindings [x xs]
(li :text x))
(li "this is also static"))
because there is a bug with insertBefore that affects things that are direct children of the body
the operations are indeed on body
done. the issue still happens 😞
that’s why it stays in the kind of… limbo state
right
makes sense.
will give it a try
just wondering though, how it’ll affect the other libraries
alas, i went through hell trying to figure out what was going on in the d3 source
so much mutation @_@
when you say loading it after hoplon is finished
do you mean putting it on a setTimeout?
just tried putting it in a timeout. now it can’t find d3 😛
also just read your link. Did he basically reimplement the DOM parts of d3 in react? o_O
i guess with hoplon the real problem is that hoplon exposes a dom that has more fundamental features than the browser dom
Time to make my own charting library 😛
The example I made for this issue doesn’t have loop-tpl. It’s just a reduced case. The reason I’m working on this, however, is an app I’m making for work.
Ideally, I’d avoid reinventing the wheel, and just use d3 for rendering the data vis stuff
but given the issues with insertBefore, I’m just using d3 to run some of the scaling calculations, and implementing the visualizations entirely in hoplon.
Since in my country, the past few days has been a series of national holidays, I decided to do due diligence to see if there’s anything at all I can do to get d3 to work with hoplon
as for a demo
I can send you a zip
will that suffice?
well alternatively i can just push it to github
actually i’ll do that
there will be a lot of console.log
s scattered around the d3.js file
@levitanong: are you looking to make normal charts and graphs for business? bar, line, pie, etc?
@raywillig: i am, but with some oddly client specific stuff, so I can’t use c3 😞
@micha: yes. It’s slightly modified to get rid of some of the tertiary conditionals
for debugging
If you like, I can replace it entirely with stock d3
ok the first thing i recommend is using this: https://github.com/cljsjs/packages/tree/master/d3
I was actually using that 😛
for my project
but for the reduced case, I wanted to do everything on the console
ah yes, i forgot to mention
just copy and paste the following in the console
i was comparing this to a setup wherein i wasn’t using hoplon
but used the exact same d3.js file
and same snippet in the console
this is how i concluded that hoplon was doing something that made certain methods behave differently
yeah, the simple stuff works
it totally breaks down when working with axes.
Do you think it’s possible to make a kind of “island” macro?
basically a piece of code that is isolated from the rest of hoplon, where it’s just vanila DOM
because I think hoplon development would stall if we had to bend over backwards trying to accommodate these JS libraries
exactly
and then it just evaluates the body
(with-foreign)
maybe
perhaps some kind of binding that allows some communication between that island and everything else?
sounds like a lot of work 😛
but that would be seamless
well, the farthest i’ve gone is their d3_selectionPrototype.insert
method
i have not tried iframes.
¯\(ツ)/¯
iframes are scary, but maybe they can work as the island...
anyway, what i found is that in d3_selectionPrototype.insert
, the call to this.insertBefore
returns different results for hoplon and vanilla.
i suppose the next step is to put in some log statements inside hoplon’s .insertBefore
, that’s alien territory for me at the moment
anyway, it’s getting pretty late here, will have to sign off. Thanks so much for your time, @micha!
Much appreciated!
@levitanong: FIXED!
@micha whoa that was fast! Now I can sleep easy
Excited for the branch :D
Also, unit tests, you say? @thedavidmeister will be pleased
Alright, off to bed for me. May the rest of your day be great, @micha!
couldn’t help it. had to test it. IT WORKS
u da man