Giter Site home page Giter Site logo

fengren / alova Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alovajs/alova

0.0 1.0 0.0 7.46 MB

Request strategy library for MVVM libraries such as Vue.js, React.js and Svelte.js

Home Page: https://alova.js.org

License: MIT License

Shell 0.05% JavaScript 1.78% TypeScript 95.39% Svelte 2.79%

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 discord qq dependency tree shaking typescript license

🔥Documentation

https://alova.js.org

🚀 Features

  • 🕶 Provide a unified experience in the vue(composition/options), 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

Breaking boundary of the usage of useHook

NOW, alova has perfect compatibility with vue options, let's enjoy it!

alova request strategy list

Alova is the core library, which provides common functions such as caching strategy, request sharing strategy, and state management, and can meet more than 99% 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
Pagination request strategy Automatically manage paging data, data preloading, reduce unnecessary data refresh, improve fluency by 300%, and reduce coding difficulty by 50% usePagination
Non-sense data interaction strategy A new interactive experience, submission and response, greatly reducing the impact of network fluctuations, allowing your application to still be available when the network is unstable or even disconnected useSQRequest
Form submission strategy A hook designed for form submission. Through this hook, you can easily implement form drafts and multi-page (multi-step) forms. In addition, it also provides common functions such as form reset useForm
File upload strategy A simpler file upload strategy that supports automatic identification and conversion of base64, Blob, ArrayBuffer, and Canvas data useUploader
Send verification code Verification code sending hook reduces the complexity of developing the verification code sending function. useCaptcha
Automatically re-pull data Automatically re-pull data under certain conditions to ensure that the latest data is always displayed. useAutoRequest
Trigger requests across components An alova middleware that eliminates component-level restrictions and quickly triggers the operation function of any request in any component actionDelegationMiddleware
UseRequest for serial requests A more concise and easy-to-use serial request use hook than alova's serial request method, providing unified loading status, error, and callback functions useSerialRequest
UseWatcher for serial requests A more concise and easy-to-use serial request use hook than alova's serial request method, providing unified loading status, error, and callback functions. useSerialWatcher
Request retry strategy Automatic retry on request failure, which plays an important role on important requests and polling requests useRetriableRequest
SSE Requests Requests via Server-sent Events useSSE

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

If you still have a specific and typical business request scene which we havn't implemented yet, you can submit an issue here, or you can also customize the request hook, please see the Advanced section.

Examples

The examples here will show the power of alova.

We really need your star

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

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 more then one year since the first version of alova. During this year, we have been continuously discovering and optimizing problems. So far, alova has passed 190+ unit tests, with a coverage rate of 99%. and it almost in a stable state. Even so, alova is still a rookie, it still has a large development space.

More framework support

Now, alova is available in vue options (vue2 and vue3), click here to view details. In the future, the following frameworks will be supported:

  • Function style such as solid/preact/qwik.
  • class style such as angular/lit/stencil.
  • options style such as native mini Program (China🇨🇳).

Join the channel community

To replace other request libraries?

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. they has provided a good support for network communication, they are an essential link (request event) in the RSM process, alova still needs to depend them to send 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

Welcome to contribute

Since its official propaganda in April 2023, alova has received 1500+ stars within 3 months.

We're honored to hear from developers around the world in Issues and Discussions.

We expect to make alova a common project for everyone who is willing to participate, instead of the alova team. We encourage everyone to become a contributor to the alova community with an open and inclusive attitude. Even if you are a junior developer, as long as your idea is in line with alova's goal, please generously participate.

Now alova is still a rookie, and it still has a long way to go. Participating in contributions now can let you win more effective contribution opportunities, and it will let developers all over the world to use your code.

We believe that contributing to alova is not only limited to code contributions, but also participating in any activities that are conducive to the development of alova is considered to contribute to alova, including the following 13 items, but not limited to these:

  1. Use alova in your project.
  2. Star alova in Github.
  3. Report bugs.
  4. Provide new feature ideas.
  5. Contribute code.
  6. Code adapter and stritegy library based on alova.
  7. Participate in community communication and PR review.
  8. Code a demo.
  9. Correct documentation or add new content.
  10. Translate documents.
  11. Publish articles, videos and other information that are conducive to the development of alova on social platforms.
  12. Project cooperation.
  13. Project donation.

and any other positive development you can think of

Contributing effectively will let you win some fame of alova community. Before participating in the contribution, please be sure to read the CONTRIBUTING in detail to ensure your effective contribution.

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.