This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-16
Channels
- # bangalore-clj (8)
- # beginners (78)
- # boot (68)
- # cljs-dev (32)
- # cljsrn (43)
- # clojars (2)
- # clojure (147)
- # clojure-italy (4)
- # clojure-nl (2)
- # clojure-quebec (1)
- # clojure-russia (19)
- # clojure-spec (17)
- # clojure-uk (25)
- # clojurescript (98)
- # clr (2)
- # core-async (14)
- # cursive (5)
- # datascript (1)
- # datomic (23)
- # emacs (4)
- # hoplon (8)
- # jobs (4)
- # kekkonen (1)
- # lein-figwheel (9)
- # off-topic (2)
- # om (2)
- # om-next (9)
- # onyx (4)
- # planck (2)
- # re-frame (14)
- # ring-swagger (3)
- # untangled (18)
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>
)
}
}
this has a very simple example of ex-navigation https://github.com/jorda0mega/boot-react-native-exponent-template
not sure what you mean by embed properties in a class? can you explain?
this part:
static route = {
navigationBar: {
title: 'Home',
}
}
(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”}}))
is there documentation on how to include externs in boot-react-native?
I see some good tutorials which run the android simulator, but I was hoping for ios
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
@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.)
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
@etherfuse Good to hear! Good luck!
@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 🙂
@vikeri so no background fetch support on iOS?
@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.
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)});
}
but your android lib is much more powerful, thanks for sharing
Alright sweet! Can you call functions even when the app is not active? Because then the Headless JS part is not necessary for iOS.
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
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.
@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.)
Nope. You need to enable background fetch in iOS project settings and implement AppDelegate.performFetchWithCompletionHandler method in any case
so like 10 lines are needed 🙂
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?
Unfortunately with RN it’s not possible to pass function reference (while actually with JavaScriptCore it is btw)
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…
haven’t used HeadlessJS so cannot say anything about it
yeah-yeah, it’s called eval for the reason 🙂
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);
}];
you can call async functions as well, there is helper there
under the hood it’s very straightforward - it just passes/receives events using DeviceEventEmitter.addListener
and bridge.eventDispatcher sendDeviceEventWithName
Hmm, interesting… It seems hard to accomplish a Obj-C-free solution before a proper HeadlessJS implementation is done for iOS.
ObjC is crap, but it’s not that hard to write couple of lines on it 🙂
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.
That’s true
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)
https://github.com/tiensonqin/lymchat/blob/master/android/app/src/main/java/com/lymchat/lymchat/MainApplication.java.example#L62 I found this example, but no clue what's going on