Wechat applet development library grace vs wepy

Both grace and wepy are open source libraries that assist in the development of small programs. This article makes a comparison between the two.

Note: This article is some of the author's own humble opinions, purely technical discussions, do not want to cause technical belief disputes, welcome positive and positive discussions and suggestions.

If you don't know Grace yet, please refer to: WeChat Mini Program Development Artifact-Grace

Github: github.com/wendux/grac…

Since the release of the applet, the most famous applet development framework is wepy. It uses a series of tools to achieve a development style close to Vue through pre-compilation. It can be considered that wepy is the vue of the applet (but there are also Some differences, such as layout templates), first of all, we must admit that wepy is a good framework. If you are a Vue developer, if you want to develop some large small program projects, wepy should be your best choice. But let's take a different angle and consider the following two questions:

Mini Program Developer Source

  1. from front-end developer

    At present, if you are a front-end, you are likely to have used one of Angular/React/Vue. First of all, if you have not used Vue, then the learning cost of using wepy is close to the cost of learning Vue. This is the first One point, the cost of learning will be higher. Secondly, for developers who have a strong belief in Angular/React, they may ask, apples are applet, why have to make Vue. In web development, authentic Vue is not needed, and will go to the development of applet Learn about wepy?

  2. non front-end developer

    After the release of the applet, most programmers want to try it, not just the front-end programmers. For this part of the developers, most of them use the native development of the applet, and they are basically reluctant to learn a software like Vue. Front-end frameworks of the same size.

To sum up, from the developer's point of view, wepy adopts a Vue-like development style, which is both an advantage and a disadvantage. The advantage is that a considerable number of Vue developers can easily transition, but the disadvantage is that it raises the threshold for other developers to use. Therefore, a lightweight and easy-to-use help tool is necessary, and grace is such a tool.

Mini Program Positioning

The positioning of the applet itself is "at your fingertips, use it up and go", to solve the historical phenomenon that you have to use the next APP if you want to do anything. After you have the applet, you don't need to install too many apps, you can only download it with a small amount of traffic when you use it for the first time. It can be seen that the applet still needs to be downloaded when it is used for the first time. In order to reduce the download waiting time and save user traffic, the applet has set the online 4M for the size of the package, which is why the "small" in the applet means. This limitation of WeChat determines that Mini Programs are generally only used to implement core functions and will not be used as complex functions . This also determines that in the development of most small programs, what we need is not a big framework that is powerful and cool, but some simple help tools, and the positioning of grace is a delicate help tool. Many small programs that I know of, even most of them are developed natively.

Here's a summary of the main differences:

  1. The positioning is different; the positioning of grace is a compact and easy-to-use auxiliary library for small program development , while wepy is a full-featured Vue-like framework.

  2. The use of grace is simple and easy to use. Wepy has a lot of learning costs for developers who do not understand Vue, and the development environment depends a lot, and the configuration is more complicated.

  3. grace is closer to native, wepy is closer to web.

Let's see what functions Grace has:

what can Grace do

Let's look at the features of grace:

  1. Lightweight, compact and easy to use
  2. Supports data responsiveness as elegant as Vue
  3. Support automatic data update, change cache, batch update
  4. Powerful network function
  5. Support for global event bus
  6. Support for passing values ​​across pages
  7. Support for mixins

The main feature is sophistication. It can be seen that the current core functions mainly involve three aspects: data, network, and events.

data

The applet is separated from the data and page rendering, so there will be a lot of setDataoperations in the development. In order to simplify the large amount of explicit data update, grace has realized the data responsiveness consistent with Vue - the data can be updated directly by assignment. At the same time, in order to avoid frequent setDataperformance consumption, grace not only supports manual batch refresh, but also can automatically track the switching between the front and the background of the page. If the page switches to the background, it will not be called again setData, but will cache the changes first, and wait until When the page is switched to the foreground, it will be refreshed uniformly, effectively avoiding unnecessary performance consumption.

The internet

Most small programs need to communicate with the background through http. To this end, grace provides a powerful, flexible, and good Promise API, and supports global request configuration, request/response interceptors, etc. More importantly, Promise-style APIs can support ES7 async/await.

event

The applet native is weak in cross-page communication. For this reason, grace provides a global event bus, and you can communicate on any page by registering/triggering events. Not only that, but grace also implements a more friendly callback for page data return based on the event bus.

In addition to these, grace also supports mixins, which provide a way to extend new functions, which can add some functions to the page globally, and developers can play by themselves.

Grace's future development

The author thinks that the magnitude of the applet is generally not too large. In order to avoid over-design, grace will always maintain the principle of compactness and ease of use, and will not add too many functions that are used less frequently. If you have any good suggestions, or want to add any new features to grace, you can file an issue on github.

Finally, post the Github address. If you think it is useful to you, welcome to star, and if you have any suggestions, welcome to issue.

Grace project address: github.com/wendux/grac…


Author: wendux
Link: https://juejin.im/post/5aa0e45af265da23a404635a The
copyright belongs to the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.
 
you may be interested in

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325069101&siteId=291194637