[Cordova] Plugin Development Architecture

Source: Internet
Author: User

[Cordova] Plugin Development Architecture Problem Scenario

When developing Cordova plugin, debugging native code is a troubling thing, because Cordova's error message is not so complete. It often takes a lot of time and spirit to find out that just one letter is wrong, virtually reducing the efficiency of development.

Solution Solutions

To increase the efficiency of Cordova plugin development, developers can accelerate development by applying the following development architectures:

Will actually provide the functionality of native Code, using the IDE encapsulated as the native Library. In this step, using the IDE to encapsulate the native Library, you can use the IDE's compile, debug, and test functions to quickly handle native code errors.

    • Reference data:

      • [Android] Build and use library

      • [IOS] Build and use the framework

    • Development architecture

The IDE encapsulates the native Library, joins the Cordova plugin project, and uses Cordova plugin syntax to encapsulate native Code to provide JavaScript usage. In this step, try to avoid the logic falls in the package native code of the plugin category, let him only the transfer function, so that can reduce the complexity of the program, and thus reduce the risk of write errors.

    • Reference data:

      • [Cordova] Introduction to plugin Development

      • [Cordova] Use Android Library in plugin

      • [Cordova] Using iOS Framework in plugin

    • Development architecture

Finally, the native Code, encapsulated as Cordova plugin, can be completed and delivered using JavaScript wrappers for a more user-friendly style for subsequent developers. In this step, because the default cordova.exec function is encapsulated, that is, to try to choose Cordova.exec as a pointcut, to provide a mock mock plugin to isolate the development of JavaScript and native code, Let the two sides of the development can be carried out separately, avoid each other's development progress. and JavaScript and native isolation of the development method, but also easier to follow-up maintenance work, to avoid exception errors spread, resulting in difficult to troubleshoot the problem of error.

    • Reference data:

      • [Cordova] Introduction to plugin Development

      • JavaScript Promise Mini-book (recommended asynchronous model)

    • Development architecture

[Cordova] Plugin Development Architecture

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.