Fork me on GitHub
#clojurescript
<
2018-10-03
>
zakwilson14:10:10

I'm new to cljs (but not to clojure) and react-native. I'm trying to use react-native-sensor-manager with re-natal and do not know how to translate the import statements here.

import React, {
  DeviceEventEmitter // will emit events that you can listen to
} from 'react-native';

import { SensorManager } from 'NativeModules';

maleghast14:10:09

@zakwilson - You may want to consider using Reagent (or similar, there are others), which is a Clojuric / Clojurescript wrapper around React. That way, as long as you don't stray into waters that are completely uncharted you won't need to translate such things.

zakwilson14:10:17

After looking at Reagent, om.next, and Rum, I picked Rum. I don't think Rum will do this for me.

zakwilson14:10:17

I'm not sure Reagent has anything for me here either. This is a library written mostly in Java that makes the sensors on an Android device available from React.

maleghast14:10:17

@zakwilson - OK, sorry... I need to ask someone, as I don't know myself, but there are Clojuric wrappers for ReactNative...

zakwilson15:10:36

Thanks for the answer. I'm sure there's a simple way to do it and it's likely just a question of syntax.

maleghast15:10:51

Almost certainly

maleghast15:10:57

*scratches head*

maleghast15:10:40

@zakwilson - Some "people I know" use this: https://github.com/seantempesta/expo-cljs-template and the docs are here: https://docs.expo.io/versions/latest/ At first look it does appear to give access to some of the Native sensors, like the Gyroscope

maleghast15:10:06

It also has a codified way to "Eject" and write native code, that looks as though it's really well documented...

idiomancy15:10:56

what predicate would I use to test to see if something supports the deref function?

idiomancy15:10:05

is there like an IDerefable or something?

mfikes15:10:20

@idiomancy (satisfies? IDeref x)

idiomancy15:10:44

oooh, didn't know about the satisfies fn!

mfikes15:10:21

In order to fish for this yourself, (source deref), then see -deref, then (source -deref) and you will see the protocol.

orestis15:10:30

That’s a common question - it popped up some days ago too. I wonder what the pattern is that prompts it :)

mfikes15:10:00

Yeah, why such a recent interest in whether something can be dereffed? :thinking_face:

idiomancy15:10:47

I sincerely doubt I am part of any kind of recent trend

mfikes15:10:00

Hah. Usually you statically know that deref is OK.

idiomancy15:10:34

yeah, totally. this has to do with a silly wrapper I made a while ago

orestis15:10:37

Is it perhaps to deal with promises?

idiomancy15:10:33

lol, well, its actually just a mechanistic consideration with a library/pattern I'm working on for working with reagent+posh(datascript)

idiomancy15:10:19

its basically defining something I call a "qpv" which is essentially a reactive var that is a composition of a datascript query, a datascript pull, and one or more view functions

idiomancy15:10:38

it uses re-frame's frp layer caching to checkpoint at each stage

idiomancy15:10:31

so, essentially the output of the whole thing is a function, but I wanted it to have a derefing syntax purely for the aesthetic notion that it should be treated as a value

idiomancy15:10:46

so the testing to see if it was derefable was just so that I could start with a known set of ids in the pull stage without having to start with a query

idiomancy15:10:30

essentially, the "pv" function takes a derefable (the output of the q step), but sometimes I just want to give it a value.

idiomancy15:10:50

but, I should probably rework that rather than testing to see if its derefable

zakwilson15:10:53

Run with --info or --debug option to get more log output. error: unknown option --debug'`

Mario C.16:10:23

How do I access this in CLJS?

Mario C.16:10:29

Or print it out

richiardiandrea17:10:58

can you folks recommend a CLJS idiomatic library for doing async calls in node? Kind of like cljs-http but for node

lilactown18:10:33

I used kvlt, since it depends on request for node: https://github.com/nervous-systems/kvlt

richiardiandrea14:10:20

I checked that, but wasn't the project archived?

lilactown16:10:09

still works ¯\(ツ)

Sal18:10:33

Looking at various articles and youtube videos I noticed there was a lot of excitement about Om Next in 2016, but it’s 2018 now and it seems things with Om next are much quiet now. Anyone have any more insight on the status of the project?

dnolen18:10:10

not that active, though there are some users of course, it more or less works as advertised

dnolen18:10:23

there are newer efforts like Fulcro that improve upon its ideas

dnolen18:10:11

haven’t had any time to use it myself, but I have noted some previous Om users are enjoying it quite a bit

Sal18:10:04

Awesome! I’ll have a look. Thank you for the info @dnolen

idiomancy18:10:55

hmm. what is '[:find ...] vs [:find ...] to the interpreter? Is there a predicate I can use to test for that? quoted or something?

idiomancy18:10:00

i suppose the question is "is there a predicate to test to see if the form is unevaluated?"

dnolen18:10:45

to be clear there is no interpretation

idiomancy18:10:28

whoop, yeah, my bad!

dnolen18:10:51

just compilation

dnolen18:10:44

in the former the compiler will emit a vector of Clojure “inert” data, the later might not to be that simple

idiomancy18:10:37

gotcha, okay

dpsutton19:10:32

can clojurescript not use "nested requires" in ztellman style? [project.protocols [x :as x] [y :as y]]

dnolen19:10:15

and no intention to support either

joelsanchez19:10:39

happy for that limitation, as well as banning :refer :all. keeping code readable and stuff

dnolen19:10:51

not really a fan of all the flexibility in Clojure’s ns

dnolen19:10:07

Rich intentionally revisited and restricted

dnolen19:10:49

we recovered most of the usability over time but we left out the extravagances - which have really shown to be low in value in projects / libraries

dpsutton19:10:24

for sure agree on refer (definitely :all). Not sure the nested thing hurts readability in my opinion. but i like when a decision is made and no ambiguity about it 🙂

aarkerio19:10:12

Hi! can I do something like:

souenzzo19:10:03

Checkout #reagent channel you will need "type-2" reagent forms

aarkerio19:10:46

I can't change the checkbox in the browser ;-(

aarkerio19:10:01

and I don't get any message in the console