From 4204b9debdf0d8967445cd065e1d901d2a72eb67 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 15 Apr 2015 22:00:44 +0000 Subject: [PATCH] update website --- docs/nativemodulesios.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/nativemodulesios.html b/docs/nativemodulesios.html index 140fcfa2b41..bff8a6d583d 100644 --- a/docs/nativemodulesios.html +++ b/docs/nativemodulesios.html @@ -14,8 +14,7 @@ } @end

Now from your JavaScript file you can call the method like this:

var CalendarManager = require('NativeModules').CalendarManager; -CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey');

NOTE: JavaScript method names -The name of the method exported to JavaScript is the native method's name up to the first colon. React Native also defines a macro called RCT_REMAP_METHOD to specify the JavaScript method's name. This is useful when multiple native methods are the same up to the first colon and would have conflicting JavaScript names.

The return type of bridge methods is always void. React Native bridge is asynchronous, so the only way to pass a result to JavaScript is by using callbacks or emitting events (see below).

Argument types #

React Native supports several types of arguments that can be passed from JavaScript code to native module:

In our CalendarManager example, if we want to pass event date to native, we have to convert it to a string or a number:

RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(NSInteger)secondsSinceUnixEpoch) +CalendarManager.addEvent('Birthday Party', '4 Privet Drive, Surrey');

NOTE: JavaScript method names

The name of the method exported to JavaScript is the native method's name up to the first colon. React Native also defines a macro called RCT_REMAP_METHOD to specify the JavaScript method's name. This is useful when multiple native methods are the same up to the first colon and would have conflicting JavaScript names.

The return type of bridge methods is always void. React Native bridge is asynchronous, so the only way to pass a result to JavaScript is by using callbacks or emitting events (see below).

Argument types #

React Native supports several types of arguments that can be passed from JavaScript code to native module:

In our CalendarManager example, if we want to pass event date to native, we have to convert it to a string or a number:

RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location date:(NSInteger)secondsSinceUnixEpoch) { NSDate *date = [NSDate dateWithTimeIntervalSince1970:secondsSinceUnixEpoch]; }

As CalendarManager.addEvent method gets more and more complex, the number of arguments will grow. Some of them might be optional. In this case it's worth considering changing the API a little bit to accept a dictionary of event attributes, like this:

#import "RCTConvert.h"