This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-11
Channels
- # beginners (132)
- # boot (2)
- # cider (17)
- # cljs-dev (6)
- # cljsrn (24)
- # clojure (134)
- # clojure-austin (2)
- # clojure-dusseldorf (11)
- # clojure-france (1)
- # clojure-greece (27)
- # clojure-italy (17)
- # clojure-madison (1)
- # clojure-russia (31)
- # clojure-serbia (1)
- # clojure-sg (2)
- # clojure-spec (30)
- # clojure-uk (66)
- # clojurescript (73)
- # core-async (2)
- # cursive (8)
- # data-science (2)
- # datomic (23)
- # dirac (8)
- # emacs (18)
- # gsoc (1)
- # hoplon (36)
- # immutant (26)
- # leiningen (6)
- # off-topic (21)
- # om (19)
- # onyx (6)
- # other-languages (1)
- # pedestal (3)
- # proton (2)
- # random (1)
- # re-frame (1)
- # reagent (2)
- # remote-jobs (2)
- # ring-swagger (8)
- # rum (21)
- # slack-help (1)
- # spacemacs (4)
- # specter (16)
- # untangled (6)
so I was just trying a lein doo phantom test once
on my project and my system almost crashed. Lein hung for a minute, showing ;; Testing with Phantom:
and my computer got sluggish.
Then PhantomJS finally crashed and dumped a bunch of these
;; ======================================================================
;; Testing with Phantom:
1 0x7f71bcc516b7 /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5(WTFCrash+0x17) [0x7f71bcc516b7]
2 0x7f71bc94e255 /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5(+0x1892255) [0x7f71bc94e255]
3 0x7f71bc946b8d /usr/lib/x86_64-linux-gnu/
...
31 0x7f71bc95bb22 /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5(+0x189fb22) [0x7f71bc95bb22]
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
And a minute later Ubuntu told me that it couldn't generate an analysis because I didn't have enough memory.this question is only half serious: is it possible to write a data filein such a way that: 1) it loads as valid javascript AND 2) reads as valid clj via slurp
@qqq transit is json and can be converted to clj ..Maybe you could give it a shot?
@richiardiandrea : looking into it; thanks!
I have a file, foo.js, which contains a single line
var my_data = "Hello world";
I have included foo.js in html via script, before my cljs dependenceis
now, how do I access "my_data" via cljs ?
I tried (oget js/document "my_data") but that can't find it
my_data is a global rightt? if so, how do I access it via js ?@john: 1) that worked; thanks! 2) why does optimizations:advanced not mungle js/my_data ?
But, if it does get munged, you can still access the property using (aget js/my_data "prop")
@qqq top level vars don't get munged, but you should still include externs for my_data
as this behavior is not guaranteed
Hey all, I'm trying to use https://github.com/facebook/react-native/blob/master/Libraries/Lists/FlatList.js - I know my problem may look like a cljsrn thing, but to me, it's a cljs thing. I seem to be able to get a FlatList
-object, however, not all FlatList
-methods seem to be available:
=> (println mylist)
#object[FlatList [object Object]]
Trying to run .scrollToEnd
doesn't do anything. Also, checking which properties and methods are available:
=> (println (.getOwnPropertyNames js/Object mylist))
#js [props context refs updater _hasWarnedLegacy _captureRef _getItem _getItemCount _keyExtractor _onViewableItemsChanged _renderItem _reactInternalInstance state _listRef]
Checking the code of FlatList
:
$ cat node_modules/react-native/Libraries/Lists/FlatList.js
/**
...
* @providesModule FlatList
* @flow
*/
'use strict';
const MetroListView = require('MetroListView'); // Used as a fallback legacy option
const React = require('React');
const ReactNative = require('ReactNative');
const View = require('View');
const VirtualizedList = require('VirtualizedList');
const invariant = require('fbjs/lib/invariant');
import type {StyleObj} from 'StyleSheetTypes';
import type {ViewabilityConfig, ViewToken} from 'ViewabilityHelper';
import type {Props as VirtualizedListProps} from 'VirtualizedList';
class FlatList<ItemT> extends React.PureComponent<DefaultProps, Props<ItemT>, void> {
static defaultProps: DefaultProps = defaultProps;
props: Props<ItemT>;
...
scrollToEnd(params?: ?{animated?: ?boolean}) {
this._listRef.scrollToEnd(params);
}
...
scrollToIndex(params: {animated?: ?boolean, index: number, viewPosition?: number}) {
this._listRef.scrollToIndex(params);
}
...
}
module.exports = FlatList;
How to make the methods of the FlatList
-class available in clojurescript?
(with-open [w ( "../resources/public/data.js")]
(.write w (str "var my_data = "))
(let [writer (transit/writer w :json)]
(transit/write writer {:foo 20})))
I wnat to open a file, then write some string to it, then write some clj data (via transwit/json) to it. How can I do that? %The above coede does not work.@kurt-o-sys, how did you define mylist?
well, here comes the part where I had to extract from the 'components state':
(defc PAQBY <
{:did-mount (fn[state]
(let [mylist (-> state
:rum/react-component ;; get react component
.-refs ;; refs property
(js->clj :keywordize-keys true)
:ref-list)] ;;get ref-list ref = the `FlatList`
(.scrollToEnd mylist)
(js/setTimeout
(fn[]
(-> state :rum/react-component rum/request-render))
2000)
state))}
[]
(view {:flex 1}
(text {:style {:fontSize 11}}
(str "last rendered: " (.toISOString (js/Date.))))
(flatlist {:data all
:keyExtractor (fn [item idx] (str "list-item::" idx))
:ref :ref-list
:renderItem #(list-item %)})
))
So I extract it from some internals... I have to do something similar as:
class ScrollToExample extends Component {
componentDidMount() {
this.list.scrollToEnd();
}
...
render() {
return (
<FlatList
...
ref={(ref) => { this.list = ref; }}
...
/>
);
}
}
so
* this.list
-> (-> state :rum/react-component .-refs (js->clj :keywordize-keys true) :ref-list)
* ref={(ref) => { this.list = ref; }}
-> :ref :ref-list
Thinking about it again, it seems .scrollToEnd
is available. It doesn't throw an error when I invoke it... But it's not executed, or not properly.
(replacing .scrollToEnd
with an unexisting method does result in an error)
What's the best exception tracker for ClojureScript?
@pupeno I use http://sentry.io + source maps.
@edbond are you happy with it? any particular reason you chose it over the thousands of others out there?
pupeno: I am quite happy, use free plan. No problems, catch javascript errors on development and production.
On dev? Do you mean, when running the app locally?
Yes, dev sends errors too. 🙂 It has console output in issues, browser/device detection and backtrace.
Don't you want exceptions to just be raised locally when in dev mode?
backtrace can be viewed minified (using sourcemap) or raw (compiled js, with error code highlighted)
Sentry aggregates similar errors, you can mark them resolved. I think other exception trackers do the same.
Yes, that's very common, although implementing it correctly is far from trivial.
I'm doing a toy web app with reagent, and would like to connect an atom to a database such that they are kept in sync - when one is modified, the other is updated. Do I need Re-frame for this, or is there a simpler way?
Or is this actually database-related as well? Do I need something specific there that will emit an event when the database changes?
I guess this is quite a bit more complex than I thought, and I have to do an actual back end for it
Synchronizing a datascript browser DB with a datomic backend DB would probably be able to provide the strongest concurrency/consistency guarantees. But still, they don't do that out-of-the-box and making them mutually ACID out of the box would still be non-trivial.
I’m using leningen and its fucking my mind. Some changes in the code base are reflected in the browser in less than 5 seconds. But often it stops auto-building and what I can see on my browser is the some old version of the code. I understand that there is a guilty of browser (chrome) as well because as soon as I clear the cache / switch to incongnito mode, it starts picking up the latest code. Kindly educate me if I’m missing anything.
@ingared, I've noticed that figwheel can have some slightly squirelly interactions with the browser cache (on Chrome at least) and I will occasionally shift-reload to clear my browser cache in the face or inexplicable errors
I've heard of some developers disabling their browser cache altogether for localhost, though for me it's not problematic enough to do that
@ingared I usually run a tail -f figwheel_server.log
on the side which can help see what's happening
So I have this then
function for dealing with asynchronous callbacks on my object. I just implemented a chain
function for it, ala https://funcool.github.io/promesa/latest/#promise-chaining
But for naming, I'm wondering if then->
sounds more idiomatic than chain
. Any opinions?
Oh, and another complication I could use advice on: then
could optionally take an extra error-fn argument. But then chain
would no longer be dealing with straight sequence of callbacks. It'd have to deal with single fns sometimes and pairs of success-fn/error-fns sometimes.
So how would you prefer the user supply those to the chain
function? '(success-fn success-fn [success-fn error-fn] success-fn [success-fn error-fn])
? Or every item be a vector of either one or two fns? Or something else?
Also, is naming then
"then" a bad idea, with respect to future compatibility, since .then
is already pretty common in JS? And if so, is there a better name I could use?
@ruh @timgilbert : Thanks for your response. @timgilbert — It would be a better option to disable the chrome caching.
Try disabling cache when devtools is open.
ugh, I've been suffering instead of disabling cache... thanks!
leiningen doesn’t do anything with browsers though - I am almost certain this is mentioned in the figwheel docs
(I'm genuinely surprised that Chrome doesn't disable cache when devtools are open by default)
In the documentation here: https://github.com/sethtrain/raven-clj what is handler/site supposed to be?
@pupeno probably http://weavejester.github.io/compojure/compojure.handler.html#var-site
I’m developing a web app using clojurescript using rum. I have defined components to query result from graphql and construct a component using data from the result,