Fork me on GitHub
#cljsrn
<
2016-12-16
>
seantempesta01:12:11

I think some of you are using exponentjs/ex-navigation? Does anyone have some sample code I could look at? I can’t figure out how to embed properties in a class:

class HomeScreen extends React.Component {
  /**
    * This is where we can define any route configuration for this
    * screen. For example, in addition to the navigationBar title we
    * could add backgroundColor.
    */
  static route = {
    navigationBar: {
      title: 'Home',
    }
  }

  render() {
    return (
      <View style={{alignItems: 'center', justifyContent: 'center', flex: 1}}>
        <Text>HomeScreen!</Text>
      </View>
    )
  }
}

jorda0mega01:12:19

not sure what you mean by embed properties in a class? can you explain?

seantempesta01:12:03

this part:

static route = {
    navigationBar: {
      title: 'Home',
    }
  }

jorda0mega01:12:13

(defn offerings-cp []
      (let [offerings (subscribe [:get-offerings])]
           (fn []
               [rn/scroll-view {:content-container-style (:scroll-view styles)}
                (for [offering @offerings]
                     [offering-row offering])])))

(defn offerings-scene
      [props]
      (util/wrap-route offerings-cp {:navigationBar {:title "Offerings"
                                                :titleStyle {:color "black"}
                                                :backgroundColor “white”}}))

jorda0mega01:12:03

is there documentation on how to include externs in boot-react-native?

etherfuse06:12:29

I’ve been trying all of the example projects and so far the first 3 fail

etherfuse06:12:50

does anyone have a basic to-do app tutorial for ios ?

etherfuse06:12:07

just looking to see how to set up a project and create some react components

etherfuse06:12:09

I see some good tutorials which run the android simulator, but I was hoping for ios

etherfuse06:12:28

also, when writing tests, what do you normally use? clojure.test or javascript frameworks? I’ve seen both, so I’m curious what the most common scenario is

vikeri07:12:28

@etherfuse Have you followed this tutorial: http://presumably.de/boot-react-native.html ? We are using doo + re-frame-test for testing. I talk a little about it here: https://youtu.be/6IYm34nDL64?t=9m3s (didn’t use re-frame-test then though.)

etherfuse07:12:47

I have not, I’ll try it out tomorrow. I was hoping to find something that had an example with a few tests. I think my issue is I’m looking at the project/core-test.cljs files in each repo, when developers must use something esle

etherfuse07:12:58

I’m super new to this

etherfuse07:12:02

Just wanted to say thanks, you’ve pointed me in the right direction

vikeri10:12:44

@etherfuse Good to hear! Good luck!

vikeri12:12:28

@jurgen_photek Just finished the background job library: https://github.com/vikeri/react-native-background-job it pure JS but should be quite easy to use from cljs 🙂

artemyarulin13:12:24

@vikeri so no background fetch support on iOS?

vikeri13:12:44

@artemyarulin Not atm, I think I need HeadlessJS for this to work. If it could be accomplished in another way I’d be keen to implement it.

artemyarulin13:12:56

I’ve been using another approach. I have my own lib https://github.com/artemyarulin/react-native-eval and basically the only thing I need is to put such code in AppDelegate.m

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
       ExecutorHandler executor = [JSEnvironment executor];
        executor(@“app.bgCall",@[some-params,],^(NSString* error, NSDictionary* resp) {
                     if (error)
                         callback(UIBackgroundFetchResultFailed);
                     else
                         callback(UIBackgroundFetchResultNewData)});
}

artemyarulin13:12:24

but your android lib is much more powerful, thanks for sharing

vikeri13:12:06

Alright sweet! Can you call functions even when the app is not active? Because then the Headless JS part is not necessary for iOS.

artemyarulin13:12:18

Nope. Your app can be unloaded or in background, but iOS will call your background fetch eventually when it’s decide to. usually once per 30 minutes

artemyarulin13:12:21

so kinda yes, Headless JS is not needed at least for me. I’ve been using this approach for a year already, everything works fine. But still you cannot implement 100% uptime background job like on Android for example, so no chat apps for example, etc.

vikeri13:12:46

@artemyarulin That is great! Combining your code with BackgroundFetch would then add similar functionality as what I currently have for Android? (I.e. not having to write any Objective-C for the person requiring the library.)

artemyarulin13:12:04

Nope. You need to enable background fetch in iOS project settings and implement AppDelegate.performFetchWithCompletionHandler method in any case

artemyarulin13:12:27

so like 10 lines are needed 🙂

vikeri13:12:04

Oh now I see, you write the actual JS code that should be evaluated by React in native land. You can’t pass it a function reference?

artemyarulin13:12:17

Unfortunately with RN it’s not possible to pass function reference (while actually with JavaScriptCore it is btw)

vikeri13:12:59

Ok, what HeadlessJS does then is to allow you to pass a reference key to a function and when it then fires up React Native it fetches that function from that key and executes it…

vikeri13:12:57

Does callSyncFunction fire up React Native? Will it execute the code in index.ios.js?

artemyarulin13:12:01

haven’t used HeadlessJS so cannot say anything about it

artemyarulin13:12:14

yeah-yeah, it’s called eval for the reason 🙂

artemyarulin13:12:51

Here full example from readme:

RCTBridge* bridge = [[RCTBridge alloc] initWithBundleURL:[NSURL URLWithString:@"URL_TO_BUNDLE"]
                      moduleProvider:nil
                      launchOptions:nil];
RCTRootView* view = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"app"];

// Call sync function
[RNMEvaluator callSyncFunction:bridge
                          name:@"Math.pow"
                          args:@[@2,@2]
                            cb:^(NSString *error, id returnValue) {
                                if (error)
                                    NSLog(@"Error occured: %@", error);
                                else
                                    NSLog(@"Function returned: %@", returnValue);
                            }];

artemyarulin13:12:42

you can call async functions as well, there is helper there

artemyarulin13:12:01

under the hood it’s very straightforward - it just passes/receives events using DeviceEventEmitter.addListener and bridge.eventDispatcher sendDeviceEventWithName

vikeri13:12:39

Hmm, interesting… It seems hard to accomplish a Obj-C-free solution before a proper HeadlessJS implementation is done for iOS.

artemyarulin13:12:34

ObjC is crap, but it’s not that hard to write couple of lines on it 🙂

vikeri13:12:00

Haha, yeah, it’s just that it is a better experience to not do it. And things like microsoft code-push does not work if you are updating native code.

andrewzhurov20:12:28

Am, hello guys. Could someone point to a good explanation how those react native ... modules/libs should be properly connected ? Interested in android part. I've tried google with no luck (surprisingly)