Giter Club home page Giter Club logo

alova's Introduction

A lightweight request strategy library, which provides targeted request strategies for different request scenarios to improve application availability and fluency, reduce server pressure, and enable applications to have excellent strategic thinking like a wise man.

English | ๐Ÿ“‘ไธญๆ–‡

npm build coverage status stars minzipped size dependency tree shaking typescript license

๐Ÿ”ฅDocumentation

https://alova.js.org

๐Ÿš€ Features

  • ๐Ÿ•ถ Provide a unified experience in the vue, react, and svelte, and seamlessly transplant
  • ๐Ÿ“‘ The api design is similar to axios, more simple and familiar
  • ๐Ÿต Out-of-the-box high-performance request strategy, making the application smoother
  • ๐Ÿฆ 4kb+, only 30% of axios+
  • ๐Ÿ”ฉ High flexibility, compatible with any request library, such as axios, superagent or fetch-api
  • ๐Ÿ”‹ 3 data cache modes to improve request performance and reduce server pressure
  • ๐Ÿ”Œ Rich extension functions, you can customize request adapter, storage adapter, middleware, and states hook
  • ๐Ÿ–ฅ๏ธ [2.2.0+]Server-side rendering(SSR)
  • ๐Ÿ’• Request sharing to avoid sending the same request at the same time
  • ๐Ÿช‘ Data pre-fetching, which means users can see information faster without waiting
  • ๐Ÿฆพ Real-time automatic status management
  • ๐ŸŽช Interactive documentation and examples
  • ๐ŸŽˆTypescript support
  • โšก Support tree shaking, which means that the production volume of alova is often less than 4kb

alova request strategy table

Alova is the core library, which provides common functions such as caching strategy, request sharing strategy, and state management, and can meet more than 95% of request requirements. At the same time, alova also provides business logic and frequently used request strategy hooks, which can be directly used in specific scenarios. The following is a list of request policy hooks provided by alova.

Name Description Documentation
Paging request strategy Automatically manage paging data, data preloading, reduce unnecessary data refresh, improve fluency by 300%, reduce coding difficulty by 50% usePagination
Non-inductive data interaction strategy A new interactive experience, submitting and responding, greatly reducing the impact of network fluctuations, making your application still available when the network is unstable or even disconnected useSQRequest
Form Submission Strategy A hook designed for form submission, through which you can easily implement form drafts, multi-page (multi-step) forms, in addition to providing common functions such as form reset useForm
Send Verification Code Verification code sending hook, which saves you the trouble of developing the verification code sending function. useCaptcha
Cross-component trigger request An alova middleware that removes the limitation of component hierarchy and quickly triggers the operation function of any request in any component actionDelegationMiddleware
serial request useRequest A more concise and easy-to-use serial request use hook than alova's serial request method, providing a unified loading Status, error, callback function useSerialRequest
Serial request useWatcher A more concise and easy-to-use serial request use hook than alova's serial request method, providing a unified loading Status, error, callback function. useSerialWatcher
Request Retry Strategy Automatic retry on request failure, it plays an important role in important requests and polling requests useRetriableRequest

More request-related business scenarios are being collected...

If you still have a specific and typical business request scenario, but we have not implemented it yet, you can submit an issue to tell us here, we Will make it available to more people. You can also customize the request hook, please see the Advanced section.

Examples

The examples here will show the power of alova.

What relationship with request libraries

The original intention of alova is to propose a solution for different request scenarios. It can implement request functions with better experience and performance more concisely and elegantly. It is an RSM implementation library, such as $.ajax, axios and fetch-api. It provides good support for request sending and response receiving. They are an indispensable part of the RSM process (request event link), and alova still needs to rely on them for requests, so we can regard alova as a request library. An armament that makes the request library even more powerful.

Library Stability

It has been nearly a year since the development of the first version of alova. During this year, we have been continuously discovering and optimizing problems. So far, alova has passed 160+ unit tests, with a coverage rate of 99%. Even so, alova is still a rookie, so I suggest you use it conservatively.

I promise to solve it as soon as possible after receiving your issue

We really need your star

If you like alova. we are very appreciate your star at the topright. it's a approval of our work.

Alternative to the requests library?

alova is a request strategy library, which was originally created to provide specific request strategy solutions for different request scenarios, so as to achieve a smooth request experience more concisely and elegantly, such as $.ajax, axios and fetch- api, etc. provide good support for request sending and response receiving, they are an essential link (request event) in the RSM process, alova still needs to rely on them to make requests, Therefore, we can regard alova as an arm of the request library, making the request library more powerful.

Why binding UI framework?

Decoupling a js library means using it in more scenarios. For example, axios can be used in nodejs, but it also means that developers need to write more template code, such as using useHooks to encapsulate axios. However, alova abandons more usage scenarios brought about by decoupling, and positions the scope of use in conjunction with the UI framework to use alova in the most streamlined way. This is for the benefit of developers and is prevalent in a UI framework. Sometimes, deep binding can provide developers with direct-use functions and improve the developer's experience without requiring too much template code.

Size comparison with other libraries

alova axios react-query vue-request vue react
minzip minzip minzip minzip minzip minzip

What is Request Scene Model (RSM)

Click here to view the detailed introduction

Install

# use npm
npm install alova --save

# use yarn
yarn add alova

Usage

Usage is here

Request scene collection

If you have thought of some specific and typical business request scenarios, you can submit an issue to tell us here, and we will implement it for More people use.

Official Ecosystem

Resources Description
@alova/mock Mock request adapter for alova.js
@alova/scene-react react request strategy library for alova.js
@alova/scene-vue vue request strategy library for alova.js
@alova/scene-svelte svelte request strategy library for alova.js
@alova/adapter-uniapp uniapp adapter for alova.js
@alova/adapter-taro taro adapter for alova.js
@alova/adapter-axios axios adapter for alova.js
@alova/adapter-xhr XMLHttpRequest adapter for alova.js

What is next?

Alova core

  • โœ… The storage time can be set as a date object, indicating that it expires at a certain point in time
  • โœ… You can set the default cache for different request methods globally. The current default is 500 seconds of memory cache for GET requests
  • โœ… Additional state management, get and update additional state across pages and modules
  • request error log printing
  • โœ… Complete offline submission function, you can submit when you are offline, and you can read offline information when you enter again
  • โœ… Request middleware design, which can manually control sending requests, status modification, etc.
  • โœ… Retry interval, maximum number of retries, etc. when silent submission fails
  • โœ… Request to share
  • โœ… Server-side rendering support
  • Performance improvements

Extensions

  • โœ… Adapters for each operating environment (Uniapp, Taro)
  • Develop extended hooks under different request scenarios through alova/scene library, providing out-of-the-box high-performance and high-experience functions [Refer to usePagination ]

Contribution Guide

Please make sure to read the Contributing Guide before making a pull request.

Welcome to submit a issue

If you encounter difficulties when using alova, whether it is a bug, or an unmet feature, you can submit an issue.

LICENSE

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.