You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/04/17 04:14:29 UTC

[14/48] incubator-weex git commit: * [doc] add notice and code example to exporting sync method documentation

* [doc] add notice and code example to exporting sync method documentation


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/65bad078
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/65bad078
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/65bad078

Branch: refs/heads/0.12-dev
Commit: 65bad078d58cb34269f5d70c23f552c4ac360c35
Parents: 692e88b
Author: \u9690\u98ce <cx...@apache.org>
Authored: Wed Mar 29 12:03:09 2017 +0800
Committer: \u9690\u98ce <cx...@apache.org>
Committed: Wed Mar 29 12:03:09 2017 +0800

----------------------------------------------------------------------
 doc/source/references/advanced/extend-to-ios.md | 64 ++++++++++++++------
 1 file changed, 47 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/65bad078/doc/source/references/advanced/extend-to-ios.md
----------------------------------------------------------------------
diff --git a/doc/source/references/advanced/extend-to-ios.md b/doc/source/references/advanced/extend-to-ios.md
index a2ffa33..2bd6f7e 100644
--- a/doc/source/references/advanced/extend-to-ios.md
+++ b/doc/source/references/advanced/extend-to-ios.md
@@ -47,7 +47,37 @@ For example: If you want to implement an address jumping function, you can achie
 @end
 ```
 
-In addition, `0.10.0` begins to support synchronous module API call, you can use macro `WX_EXPORT_METHOD_SYNC` to export module methods which could make JavaScript receive return values from native,  it **can only be called on JS thread**.
+#### export synchronous methods <span class="api-version">v0.10+</span> 
+
+If you want to export synchronous methods which could make Javascript receive return values from natvie, you can use `WX_EXPORT_METHOD_SYNC`  macro. 
+
+native code:
+
+```objective-c
+@implementation WXEventModule
+
+WX_EXPORT_METHOD_SYNC(@selector(getString))
+  
+- (NSString *)getString
+{
+    return @"testString";
+}
+
+@end
+```
+
+js code:
+
+```javascript
+const eventModule = weex.requireModule('event')
+const returnString = syncTest.getString()  // return "testString"
+```
+
+You can alse return number/array/dictionary except string.
+
+`notice:`  the exported synchronous native method **can only be called on JS thread**.
+
+`notice:`  Vue 2.0 has not supported this feature yet. 
 
 #### Register the module
 
@@ -194,19 +224,19 @@ A Native Component has a life cycle managed by Weex. Weex creates it, layout it,
 
 Weex offers component life cycle hooks that give you visibility into these key moments and the ability to act when they occur.
 
-method| description
-:----:|------
-initWithRef:type:...| Initializes a new component using the specified  properties.
-layoutDidFinish | Called when the component has just laid out.
-loadView   | Creates the view that the component manages.
-viewWillLoad | Called before the load of component's view .
-viewDidLoad | Called after the component's view is loaded and set.
-viewWillUnload | Called just before releasing the component's view.
-viewDidUnload | Called when the component's view is released.
-updateStyles:| Called when component's style are updated.
-updateAttributes:| Called when component's attributes are updated.
-addEvent:| Called when adding an event to the component.
-removeEvent:| Called when removing an event frome the component.
+|        method        | description                              |
+| :------------------: | ---------------------------------------- |
+| initWithRef:type:... | Initializes a new component using the specified  properties. |
+|   layoutDidFinish    | Called when the component has just laid out. |
+|       loadView       | Creates the view that the component manages. |
+|     viewWillLoad     | Called before the load of component's view . |
+|     viewDidLoad      | Called after the component's view is loaded and set. |
+|    viewWillUnload    | Called just before releasing the component's view. |
+|    viewDidUnload     | Called when the component's view is released. |
+|    updateStyles:     | Called when component's style are updated. |
+|  updateAttributes:   | Called when component's attributes are updated. |
+|      addEvent:       | Called when adding an event to the component. |
+|     removeEvent:     | Called when removing an event frome the component. |
 
 
 As in the image component example, if we need to use our own image view, we can override the `loadView` method.
@@ -287,9 +317,9 @@ for example:
    }
 @end
 ```
-   
+
 after your registration for your own custom component, now you can call it in your js file.
- 
+
 ```html
 <template>
   <mycomponent id='mycomponent'></mycomponent>
@@ -301,4 +331,4 @@ after your registration for your own custom component, now you can call it in yo
     }
   }
 </script>
-``` 
\ No newline at end of file
+```
\ No newline at end of file