Web App tiering Architecture (based on Vue+router+vuex)

Source: Internet
Author: User

First, layered architecture

  The 1.Web app is divided into three layers: the behavioral layer, the data storage layer and the protocol layer, and the division of the layers is very clear.

A. The behavioral layer, embodied in the. Vue component and routing, holds some simple data that is primarily used to interact with users in a timely manner.

B. The data storage layer, reflected in the Vuex, the popular point is to store and process the requested data

C. The protocol layer is the acquisition of data (including requests and local access, etc.)

  2. For three-layer direct base constraints

    1. Data/function calls cannot span layers (except for functional interfaces, such as requests that have just entered the page)

2. Data processing should be done in the store

The 3.view layer can only do simple processing of the data in the store (e.g. data filtering for user-defined conditions)

4. Request written in the store action

5.websocket/server pushes data to be processed in the store (otherwise a memory leak may occur)

Second, the synchronous operation process

  

Question: Why can't I call the data in store directly?

Answer: Because state is updated in real time, mutations cannot perform asynchronous operations, and if you modify state directly, you can operate asynchronously, and when you operate asynchronously on the state, you are not done, and if the state has been modified elsewhere, This can cause problems with the program. So state to synchronize operations, by mutations the way to limit the asynchronous not allowed.

Iii. Asynchronous Operation Flow

Web App tiering Architecture (based on Vue+router+vuex)

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.