Fork me on GitHub
#cljsrn
<
2016-07-27
>
pvinis07:07:23

so in re-natal, in the sample app, if i wanna set the greeting when pressing the button, i would call (dispatch [:set-greeting "bla"])?

pvinis07:07:52

i mean is that the way to do it. i know it works, but is that the “cljsrn” way?

pvinis07:07:05

also, i want to have persistent storage of the db, so i keep the greeting after app restart. i found AsyncStorage. is there an example of usage with re-natal?

drapanjanas08:07:06

@pvinis: calling dispatch is the re-frame way of changing the global app state. You can read the re-frame docs they are very well written. I know luno example app uses persistent storage take a look there

pvinis08:07:01

re-natal should link users to re-frame docs..

drapanjanas08:07:35

Btw there are other options of what you can use like om-next or rum which are not using re-frame for state handling. And there changing state is done differently, so I guess there is no one "cljsrn" way of doing this.

pesterhazy09:07:47

yeah, cljsrn should be less opinionated about which react-wrapper to use; it works fine with any of those

pesterhazy09:07:23

by the way, my boot-react-native branch is now updated to React Native 0.29.2 and ready for testing: https://github.com/pesterhazy/boot-react-native/tree/develop

seantempesta09:07:34

but it would be nice if we could share more code. I still hope one day re-natal and boot-react-native will join forces. 🙂

pesterhazy09:07:56

I'm hoping to get it merged into boot-react-native master soon

pesterhazy09:07:48

if anyone could give it a try, that'd be appreciated

pvinis11:07:57

yea like seantempesta says. it would be cool if they merge. i prefer boot, but re-natal seems to work better for now

drapanjanas13:07:23

I remember thoughts about custom packager implementation. I think it would be cool to have a lightweight packager which we could use for development and make it work for boot and lein. But I have no clue how hard it would be to implement

pesterhazy13:07:44

it's important I think to decomplect the tools. The cljs-packager integration should be agnostic of the react wrapper, for example, or of additional libraries like re-frame or pre-built RN components.

drapanjanas13:07:16

I agree I imagine it would just take the js file compiled with optimizations none and transform it to whatever original packager emmits including required external libs static images and etc

pvinis15:07:55

i am trying to add react-native-store to my project but i keep getting Requiring unknown module "react-native-store/Store".If you are sure the module is there, try restarting the packager or running "npm install”

savelichalex15:07:57

@pvinis: are you use re-natal?

savelichalex15:07:00

re-natal use-component react-native-store
re-natal use-figwheel

pvinis15:07:47

i did use-component

pvinis15:07:56

i did use-figwheel now too

petterik15:07:41

Can you see react-native-store the modules of your .re-natal file? Then re-running re-natal use-figwheel should work.

seantempesta15:07:55

you’ll have to re-run lein figwheel ios too since use-figwheel does a clean first

seantempesta15:07:34

it’d be nice to change that behavior. I’ve forgotten to do that like 10 times already

pvinis15:07:40

yes it is in the .re-natal file and in package.json

seantempesta15:07:26

Try opening this link in a browser and see if you can find the ‘react-native-store’ in the output: localhost:8081/index.ios.bundle

pvinis15:07:30

btw, is there a specific order to run npm start, lein figwheel ios, and Run in Xcode?

seantempesta15:07:38

I don’t think so. I usually run lein figwheel ios and hit run in Xcode around the same time

pvinis16:07:31

and is this (def Store (js/require "react-native-store/Store”)) how i use it?

pvinis16:07:55

i saw there is this on the re-natal site, and (set! js/Store (js/require "react-native-store")) on luno

pvinis16:07:01

both give me the same error still

pvinis16:07:13

that i should do a npm install..

seantempesta16:07:49

well, let’s start lower down in the process. Is it in the output in your index.ios.bundle?

pvinis16:07:59

also, i keep getting

Error: Error validating module options: child "platform" fails because ["platform" must be a string]
    at declareOpts.js:60:13
    at Promise.resolve.then (index.js:248:20)
    at tryCallOne (/Users/pvinis/Source/pvinis/cashish/node_modules/promise/lib/core.js:37:12)
    at /Users/pvinis/Source/pvinis/cashish/node_modules/promise/lib/core.js:123:15
    at flush (/Users/pvinis/Source/pvinis/cashish/node_modules/asap/raw.js:50:29)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
this even though the app runs fine. it happens sometimes.. randomly

pvinis16:07:06

ok let me check

pvinis16:07:43

module.exports=store;
}, "react-native-store/lib/index.js");
__d(633 /* react-native-store/lib/store.js */, function(global, require, module, exports) {'use strict';

seantempesta16:07:49

the platform error is separate actually. you can fix it by running re-natal enable-source-maps

seantempesta16:07:30

okay, good. then try just running (js/require “react-native-store/Store”) in your repl

seantempesta16:07:19

actually, I think you want to just run (js/require "react-native-store")

pvinis16:07:28

ok it works

pvinis16:07:41

it returns nil so i guess it loaded

seantempesta16:07:53

hmm, no nil would mean it doesn’t load

pvinis16:07:02

yea.. it gave nil

pvinis16:07:06

and i got the redbox

pvinis16:07:18

to do npm install again

pvinis16:07:36

ExceptionsManager.js:61 Requiring unknown module "react-native-store/Store".If you are sure the module is there, try restarting the packager or running "npm install”.

pvinis16:07:52

this is weird..

seantempesta16:07:56

did you try doing the js/require w/o the /Store?

pvinis16:07:44

let me try without

pvinis16:07:48

#object[Store [object Object]]

pvinis16:07:50

ok that worked

seantempesta16:07:52

yeah, that’s it

pvinis16:07:30

so do i use it with the set! way?

seantempesta16:07:22

yeah, you gotta translate ES6 (or whatever import is) into normal javascript. I use http://babeljs.io/repl to help me: import Store from 'react-native-store’; =

'use strict';

var _reactNativeStore = require('react-native-store');

var _reactNativeStore2 = _interopRequireDefault(_reactNativeStore);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

seantempesta16:07:13

you don’t have to set! it unless you want to pollute the global namespace. You can just (def Store (js/require “react-native-store”)) and reference the Store in your code

pvinis16:07:32

oh it works yea

pvinis16:07:55

so i shouldnt have added the /Store in the end

pvinis16:07:13

im getting so confused with that stuff sometimes

pvinis16:07:30

and i cant find many references and examples

seantempesta16:07:49

yup. javascript is a pain in the ass. 🙂

pvinis16:07:52

thank you though!

pvinis16:07:21

yes.. and cljs makes things nicer, but when you interact with js, its back to the same confusion

seantempesta16:07:23

no problem. Don’t forget to (clj->js {}) any arguments if you call it