You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by Hanks10100 <gi...@git.apache.org> on 2018/04/23 08:13:53 UTC

[GitHub] incubator-weex pull request #1124: [jsfm] Support import script dynamically ...

GitHub user Hanks10100 opened a pull request:

    https://github.com/apache/incubator-weex/pull/1124

    [jsfm] Support import script dynamically at runtime

    The code here partially supports the feature of import script dynamically at runtime. It needs native render engines to implement the corresponding features to fully support it.
    
    ## API
    
    ```typescript
    weex.importScript(url: string): Promise
    ```
    
    Import javascript code from remote and run it in the current context. It takes a url string as the only argument and return a Promise, which will be fullfilled once the code is successfully executed.
    
    ## Usage
    
    ```js
    weex.importScript('https://whatever.com/shared.js')
        .then(() => {
            console.log('Import and run script success!')
        })
        .catch(() => {
            console.log('Failed to import script dynamically')
        })
    ```

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

    $ git pull https://github.com/Hanks10100/incubator-weex jsfm-feature-import-script

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

    https://github.com/apache/incubator-weex/pull/1124.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 #1124
    
----
commit e2395567f85d21dbb03916dedafd41554e0ff4cd
Author: Hanks <zh...@...>
Date:   2018-04-23T08:01:20Z

    + [jsfm] support import script dynamically at runtime

----


---

[GitHub] incubator-weex issue #1124: [jsfm] Support import script dynamically at runt...

Posted by weex-bot <gi...@git.apache.org>.
Github user weex-bot commented on the issue:

    https://github.com/apache/incubator-weex/pull/1124
  
    
    <!--
      0 failure: 
      0 warning: 
      2 messages
      
    -->
    
    
    
    <table>
      <thead>
        <tr>
          <th width="50"></th>
          <th width="100%" data-danger-table="true">Messages</th>
        </tr>
      </thead>
      <tbody><tr>
          <td>:book:</td>
          <td>has no jsfm file changed.</td>
        </tr>
      
    <tr>
          <td>:book:</td>
          <td>jsfm test finished.</td>
        </tr>
      </tbody>
    </table>
    
    
    <p align="right">
      Generated by :no_entry_sign: <a href="http://github.com/danger/danger-js/">dangerJS</a>
    </p>



---

[GitHub] incubator-weex pull request #1124: [jsfm] Support import script dynamically ...

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

    https://github.com/apache/incubator-weex/pull/1124


---

[GitHub] incubator-weex pull request #1124: [jsfm] Support import script dynamically ...

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

    https://github.com/apache/incubator-weex/pull/1124#discussion_r184579393
  
    --- Diff: runtime/api/WeexInstance.js ---
    @@ -128,6 +129,31 @@ export default class WeexInstance {
         return null
       }
     
    +  importScript (src, options = {}) {
    +    const id = getId(this)
    +    const taskCenter = getTaskCenter(id)
    +    return new Promise((resolve, reject) => {
    +      if (!taskCenter || typeof !taskCenter.send === 'function') {
    --- End diff --
    
    `typeof !taskCenter.send === 'function' ` should be `typeof taskCenter.send !== 'function'`


---