You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by zshshr <gi...@git.apache.org> on 2017/11/28 09:41:42 UTC

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

GitHub user zshshr opened a pull request:

    https://github.com/apache/incubator-weex-site/pull/15

    * [doc] update the document of extend-android

    1. update  the document of extend-android and fix some mistakes

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zshshr/incubator-weex-site master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-weex-site/pull/15.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #15
    
----

----


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162041034
  
    --- Diff: source/guide/extend-android.md ---
    @@ -5,70 +5,63 @@ group: Extend
     order: 6.3
     version: 2.1
     ---
    +# Android extend
    +  Weex provides an easy way to extend, as module-extend、component-extend and adapter-extend.
     
     ## Module extend
     
    -weex sdk support Module extend, Weex SDK provides only rendering capabilities, rather than have other capabilities, such as network, picture, and URL redirection. If you want the these features, you need to implement it.
    -
    -For example: If you want to implement an address jumping function, you can achieve a Module Follow the steps below.
    -
    -### Step to customize a module
    -
    -- Customize module must extend WXModule
    -- @WXModuleAnno annotation must be added, as it is the only the way to recognized by Weex
    -- The access levels of mehtod must be **public**
    -- The module class also can not be an inner class
    -- Customize can not be obfuscated by tools like ProGuard
    -- Module methods will be invoked in UI thread, do not put time consuming operation there
    -- Weex params can be int, double, float, String, Map, List
    +1. Customize module class must extends WXModule. 
    +2. Extended method must add `@JSMethod (uiThread = false or true)` annotation, and you can set the method whether it is running on UI thread or not.
    +3. The access levels of mehtod must be `public`.
    +4. Do not be obfuscated by tools like ProGuard.
    +5. Extended method suppport the data type of int, double, float, String, Map, List as its param.
    +7. Register the module: `WXSDKEngine.registerModule("myModule", MyModule.class);`or else may report an error: `ReportException :undefined:9: TypeError: Object #<Object> has no method 'xxx'` .
     
     Refer to the following example:
     
     ```java
    -public class WXEventModule extends WXModule{
    -
    -  private static final String WEEX_CATEGORY="com.taobao.android.intent.category.WEEX";
    +public class MyModule extends WXModule{
     
    -  @WXModuleAnno
    -    public void openURL(String url){
    -      //implement your module logic here
    -    }
    -}
    -```
    -
    -#### Support synchronous/asynchronous callback
    -
    -You can add  `@JSMethod (uiThread = false or true)` annotation to choose the callback mode of moudle. See the follow example.
    -
    -```java
    -  // as sync-callback mode
    -@JSMethod (uiThread = false)
    -public void testSyncCall(){
    -    WXLogUtils.d("WXComponentSyncTest : Thread.currentThread().getName());
    -}
    +  //run ui thread 
    +  @JSMethod (uiThread = true)
    +  public void printLog(String msg) {
    +    Toast.makeText(mWXSDKInstance.getContext(),msg,Toast.LENGTH_SHORT).show();
    +  }
     
    -// as async-callback mode
    -@JSMethod (uiThread = true)
    -public void testAsyncCall(){
    -    WXLogUtils.e("WXComponentASynTest : Thread.currentThread().getName() );
    +  //run JS thread 
    +  @JSMethod (uiThread = false)
    +  public void fireEventSyncCall(){
    +   //implement your module logic here
    +  }
     }
     ```
    -
    -### Register the moulde
    +Register the module
     
     ```java
    -WXSDKEngine.registerModule("event", WXEventModule.class);
    +WXSDKEngine.registerModule("MyModule", WXEventModule.class);
     ```
    -
    -### Use this module in weex DSL
    +Use this module in weex DSL
     Now `event` moudle is avaiable in weex, use the module like this:
     
    -```javascript
    -var event = weex.requireModule('event');
    -event.openURL("http://www.github.com");
    +```html
    +<template>
    +  <div>
    +    <text onclick="click">testMyModule</text>
    +  </div>
    +</template>
    +
    +<script>
    +  module.exports = {
    +    methods: {
    +      click: function() {
    +        weex.requireModule('myModule').printLog("I am a weex Module!");
    --- End diff --
    
    Maybe it's convenient to add a "uiThread = false" example.


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162040671
  
    --- Diff: source/guide/extend-android.md ---
    @@ -5,70 +5,63 @@ group: Extend
     order: 6.3
     version: 2.1
     ---
    +# Android extend
    +  Weex provides an easy way to extend, as module-extend、component-extend and adapter-extend.
     
     ## Module extend
     
    -weex sdk support Module extend, Weex SDK provides only rendering capabilities, rather than have other capabilities, such as network, picture, and URL redirection. If you want the these features, you need to implement it.
    -
    -For example: If you want to implement an address jumping function, you can achieve a Module Follow the steps below.
    -
    -### Step to customize a module
    -
    -- Customize module must extend WXModule
    -- @WXModuleAnno annotation must be added, as it is the only the way to recognized by Weex
    -- The access levels of mehtod must be **public**
    -- The module class also can not be an inner class
    -- Customize can not be obfuscated by tools like ProGuard
    -- Module methods will be invoked in UI thread, do not put time consuming operation there
    -- Weex params can be int, double, float, String, Map, List
    +1. Customize module class must extends WXModule. 
    +2. Extended method must add `@JSMethod (uiThread = false or true)` annotation, and you can set the method whether it is running on UI thread or not.
    +3. The access levels of mehtod must be `public`.
    +4. Do not be obfuscated by tools like ProGuard.
    --- End diff --
    
    Do not obfuscate code using tools like ProGuard.


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162041187
  
    --- Diff: source/guide/extend-android.md ---
    @@ -88,131 +81,149 @@ At the javascript side, call the module with javascript function to receive call
     event.openURL("http://www.github.com",function(resp){ console.log(resp.result); });
     ```
     
    -### Component extend
    -
    -There are label, image, div, scroll, ect. components in weex, you can also customize your own components.
    -
    -#### Step to customize a component
    +## Component extend
     
     1. Customize components must extend WXComponent or WXContainer
    --- End diff --
    
    extend from


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-weex-site/pull/15


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162039985
  
    --- Diff: source/guide/extend-android.md ---
    @@ -5,70 +5,63 @@ group: Extend
     order: 6.3
     version: 2.1
     ---
    +# Android extend
    +  Weex provides an easy way to extend, as module-extend、component-extend and adapter-extend.
     
     ## Module extend
     
    -weex sdk support Module extend, Weex SDK provides only rendering capabilities, rather than have other capabilities, such as network, picture, and URL redirection. If you want the these features, you need to implement it.
    -
    -For example: If you want to implement an address jumping function, you can achieve a Module Follow the steps below.
    -
    -### Step to customize a module
    -
    -- Customize module must extend WXModule
    -- @WXModuleAnno annotation must be added, as it is the only the way to recognized by Weex
    -- The access levels of mehtod must be **public**
    -- The module class also can not be an inner class
    -- Customize can not be obfuscated by tools like ProGuard
    -- Module methods will be invoked in UI thread, do not put time consuming operation there
    -- Weex params can be int, double, float, String, Map, List
    +1. Customize module class must extends WXModule. 
    --- End diff --
    
    must extend from.


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162039801
  
    --- Diff: source/guide/extend-android.md ---
    @@ -5,70 +5,63 @@ group: Extend
     order: 6.3
     version: 2.1
     ---
    +# Android extend
    +  Weex provides an easy way to extend, as module-extend、component-extend and adapter-extend.
    --- End diff --
    
    This sentance does not make sense...


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162040271
  
    --- Diff: source/guide/extend-android.md ---
    @@ -5,70 +5,63 @@ group: Extend
     order: 6.3
     version: 2.1
     ---
    +# Android extend
    +  Weex provides an easy way to extend, as module-extend、component-extend and adapter-extend.
     
     ## Module extend
     
    -weex sdk support Module extend, Weex SDK provides only rendering capabilities, rather than have other capabilities, such as network, picture, and URL redirection. If you want the these features, you need to implement it.
    -
    -For example: If you want to implement an address jumping function, you can achieve a Module Follow the steps below.
    -
    -### Step to customize a module
    -
    -- Customize module must extend WXModule
    -- @WXModuleAnno annotation must be added, as it is the only the way to recognized by Weex
    -- The access levels of mehtod must be **public**
    -- The module class also can not be an inner class
    -- Customize can not be obfuscated by tools like ProGuard
    -- Module methods will be invoked in UI thread, do not put time consuming operation there
    -- Weex params can be int, double, float, String, Map, List
    +1. Customize module class must extends WXModule. 
    +2. Extended method must add `@JSMethod (uiThread = false or true)` annotation, and you can set the method whether it is running on UI thread or not.
    --- End diff --
    
    Extended method must add `@JSMethod (uiThread = false or true)` annotation,  which determines whether the method is run on UI thread.


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162041587
  
    --- Diff: source/guide/extend-android.md ---
    @@ -88,131 +81,149 @@ At the javascript side, call the module with javascript function to receive call
     event.openURL("http://www.github.com",function(resp){ console.log(resp.result); });
     ```
     
    -### Component extend
    -
    -There are label, image, div, scroll, ect. components in weex, you can also customize your own components.
    -
    -#### Step to customize a component
    +## Component extend
     
     1. Customize components must extend WXComponent or WXContainer
    -2. @WXComponentProp(name=value(value is attr or style of dsl)) for it be recognized by weex SDK.
    +2. With the `@WXComponentProp(name = value(value is attr or style))`annotation to automatically update the attribute or style for it be recognized by weex SDK.
    --- End diff --
    
    Use the `@WXComponentProp(name = value(value is attr or style))` annotation to let the update of attribute or style be recognized automatically.


---

[GitHub] incubator-weex-site pull request #15: * [doc] update the document of extend-...

Posted by cxfeng1 <gi...@git.apache.org>.
Github user cxfeng1 commented on a diff in the pull request:

    https://github.com/apache/incubator-weex-site/pull/15#discussion_r162040312
  
    --- Diff: source/guide/extend-android.md ---
    @@ -5,70 +5,63 @@ group: Extend
     order: 6.3
     version: 2.1
     ---
    +# Android extend
    +  Weex provides an easy way to extend, as module-extend、component-extend and adapter-extend.
     
     ## Module extend
     
    -weex sdk support Module extend, Weex SDK provides only rendering capabilities, rather than have other capabilities, such as network, picture, and URL redirection. If you want the these features, you need to implement it.
    -
    -For example: If you want to implement an address jumping function, you can achieve a Module Follow the steps below.
    -
    -### Step to customize a module
    -
    -- Customize module must extend WXModule
    -- @WXModuleAnno annotation must be added, as it is the only the way to recognized by Weex
    -- The access levels of mehtod must be **public**
    -- The module class also can not be an inner class
    -- Customize can not be obfuscated by tools like ProGuard
    -- Module methods will be invoked in UI thread, do not put time consuming operation there
    -- Weex params can be int, double, float, String, Map, List
    +1. Customize module class must extends WXModule. 
    +2. Extended method must add `@JSMethod (uiThread = false or true)` annotation, and you can set the method whether it is running on UI thread or not.
    +3. The access levels of mehtod must be `public`.
    --- End diff --
    
    The access level


---