Fork me on GitHub
#cljsrn
<
2020-07-16
>
Oliver George06:07:30

Pretty sure there are other similar issues to come.

bhauman13:07:11

@raspasov just set the :connect-url

raspasov21:07:02

@U064J0EFR I tried that, it doesn’t seem to get used in the generated index.js, it defaults to “localhost”; I have figwheel-main.edn like:

{:ring-server-options {:port 9500 :host "192.168.1.62"}}
… and ios.cljs.edn like:
^{:react-native :cli} 
{:main rf.shared.main}
So in that case when I launch the repl I get: [Figwheel] Starting Server at http://192.168.1.62:9500 But in the index.js I still get “localhost”:
import {npmDeps} from "./target/public/cljs-out/ios_rn/npm_deps.js";
import {assets} from "./target/public/cljs-out/ios/krell_assets.js";
import {krellNpmDeps} from "./target/public/cljs-out/ios/krell_npm_deps.js";
var options = {optionsUrl: "",
               autoRefresh: true};
var figBridge = require("./target/public/cljs-out/ios_rn/figwheel-bridge.js");
figBridge.shimRequire({...assets, ...krellNpmDeps, ...npmDeps});
import {AppRegistry} from 'react-native';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName,
                              () => figBridge.createBridgeComponent(options));
In the generated output under /target/public/cljs-out/ios/cljsc_opts.json there’s also:
{"figwheel.repl.connect_url":"ws:\/\/localhost:9500\/figwheel-connect?fwprocess=93622e&fwbuild=ios"}

bhauman21:07:40

no the :connect-url set that

bhauman21:07:48

in your cljs.edn

raspasov21:07:19

ah, the ios.cljs.edn ?

raspasov21:07:33

Thanks for looking into this, I feel like I’m missing something obvious 🙂

bhauman21:07:18

:connect-url

raspasov21:07:51

^{:react-native :cli
  :connect-url ""}
{:main rf.shared.main}

bhauman21:07:03

yeah that should work

raspasov21:07:05

Like that? I believe I tried that, but I’ll try again

bhauman21:07:30

also make sure that the compile is completing

raspasov21:07:16

If I manually change the “localhost” to local ip in the generated output it all works

bhauman21:07:33

actually it should pick up the :host option

bhauman21:07:12

do me a favor and set :clean-ouputs true

raspasov21:07:16

Yea, it’s strange, it doesn’t pick it up with this either:

raspasov21:07:38

no problem, trying

raspasov21:07:57

ios.cljs.edn

^{:react-native :cli
  :connect-url ""
  :clean-ouputs true}
{:main rf.shared.main}

raspasov21:07:19

^{:react-native :cli
  :connect-url ""
  :clean-outputs true}
{:main rf.shared.main}

raspasov21:07:25

(corrected spelling)

bhauman21:07:29

that way it deletes everything

bhauman21:07:37

and recompiles from scratch

bhauman21:07:11

wait are you on the latest version?

raspasov21:07:46

Yes, 0.2.10

bhauman21:07:18

and the index.js still has the wrong address in it?

raspasov21:07:27

(I’ve been using the figwheel https://github.com/bhauman/react-native-figwheel-bridge so just trying to migrate)

raspasov21:07:00

yes, localhost 😞

bhauman21:07:36

well that’s weird going to check it now

raspasov21:07:38

It’s not the biggest of issues; something weird with how the config get read… I tried looking through the source code but couldn’t quite make sense of it all

raspasov21:07:50

source code of how the index.js gets written

raspasov21:07:25

If I just stick to “localhost” everywhere and open the simulator on the local computer it all loads

raspasov21:07:47

So everything is working, it seems like a simple config issue….

raspasov21:07:10

(Same if I change to the IP manually and reload on the device - it works)

raspasov21:07:55

I have to change it in two locations: index.js target/public/cljs-out/ios/cljsc_opts.json

raspasov21:07:09

Change the

{"figwheel.repl.connect_url":"ws:\/\/localhost:9500\/figwheel-connect?fwprocess=34417a&fwbuild=ios"}

bhauman21:07:19

yeah do you have a figwheel.edn?

raspasov21:07:48

figwheel-main.edn ?

raspasov21:07:51

{:ring-server-options {:port 9500 :host "192.168.1.62"}
 }

raspasov21:07:16

That’s it

raspasov21:07:35

And the ios.cljs.edn currently is:

^{:react-native :cli
  :connect-url ""
  :clean-outputs true}
{:main rf.shared.main}

raspasov21:07:47

I tried different options, deleting the figwheel-main.edn; putting all the config in ios.cljs.edn - it changes the IP when it says: [Figwheel] Starting Server at http://192.168.1.62:9500 But in the react-native generated files, keeps defaulting to “localhost”

bhauman21:07:15

cool I’m looking at it now

👍 3
raspasov21:07:16

If I delete all the IP-related config, it all goes to localhost and it works on the simulator on the laptop

bhauman21:07:51

OK I’m getting the same behavior

bhauman21:07:58

maybe I lost a commit

bhauman21:07:40

found the bug

bhauman21:07:46

it was a refactor bug

bhauman21:07:49

sorry about that

raspasov21:07:00

No worries, thanks so much for looking into it so fast 🙂

bhauman21:07:11

should have just taken your work for it

raspasov21:07:41

No problem, glad we could re-produce

bhauman21:07:45

0.2.11-SNAPSHOT is pushed with the change, it supports :host and connect-url , use host when you want to set the server’s listening ip, use :connect-url when you are connecting to a different address than your local one

parrot 3
bhauman21:07:10

it will be deployed after the tests run

raspasov21:07:07

Thank you! 🙂

raspasov21:07:10

Just tried it, seems to work! 🙂 IPs are set correctly in index.js and cljsc_opts.json based on

{:ring-server-options {:port 9500 :host "192.168.1.62"}}

👍 3
dnolen14:07:56

@olivergeorge thanks for looking into will take a look later today

Luca20:07:36

Hi guys what is the best practice when it comes to saving user input and saving it? e.g. a person writing a todo in the app storage and persisting it?

Oliver George20:07:49

Good question. I’m interested to see what answers you get. SQLite and AsyncStorage are good conservative options.

raspasov21:07:14

@luca.cambiaghi for non-encrypted storage AsyncStorage works well; for encrypted stuff I’ve used https://github.com/oblador/react-native-keychain and that’s a nice to use library also

raspasov21:07:05

Not sure about the limitation of storing huge blobs of todo in keychain; perhaps AsyncStorage is the way to go; another Clojure-style option would be writing to DataScript and serializing it to disk

Oliver George22:07:49

DataScript + serializing is nice but if you have lots of data it can be slow and cause UX issues.

joshmiller23:07:24

@olivergeorge What size data have you gotten to where it’s slow?

Oliver George23:07:06

It was a while back and we've moved on from that approach. SQLite is less convenient but it means we're not holding lots of memory or trying to serialize/deserialize large amounts of data. The SQLite DB we package with the app is 1.8M.

Oliver George23:07:35

The reference data was every site, building, room and floor of a university we work with.

Oliver George23:07:32

When someone works out how to put datascript in front of SQLite I'll be very interested.

joshmiller23:07:49

Gotcha. I’m in the 100s of KB without running into issues, so nowhere close.

joshmiller23:07:59

I should test it to see where it starts becoming an issue.

Oliver George23:07:15

Yep, remember you probably test on fast devices & simulators too

joshmiller23:07:27

Yeah, good point.

Oliver George23:07:40

We put some logging on the re-frame handlers doing the work.