All Projects → niqingyang → mobx-loading

niqingyang / mobx-loading

Licence: Apache-2.0 license
参考了 dva-loading 的思路,基于 mobx 实现了用于监控各个 mode 和 effect 加载状态的组件

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mobx-loading

taro-template
可用于生产环境的taro项目模版,技术栈:taro + taro-ui + typescript + dva / mobx + sass,无需过多关注项目配置,预置功能包括但不限于页面/组件/store/service模版一键生成/编译自动生成路由列表和组件入口/代码规范强制检查/请求拦截封装/小程序CI等,实现多端项目的高效快速开发。目前已有1.x / 2.x / 3.x 版本。
Stars: ✭ 59 (+156.52%)
Mutual labels:  mobx, dva
Alldemo
🍑 2020全栈学习Demo大合集 包含最新 hooks TS 等 还有umi+dva,数据可视化等实战项目 (持续更新中)
Stars: ✭ 189 (+721.74%)
Mutual labels:  mobx, dva
react-mobx
No description or website provided.
Stars: ✭ 25 (+8.7%)
Mutual labels:  mobx
umi-dva-typescript-mock
基于umi + dva + typescript + mock + antd的react框架,内置PWA
Stars: ✭ 17 (-26.09%)
Mutual labels:  dva
mobx-nextjs-root-store
Mobx root store implementation for next.js with server-side rendering
Stars: ✭ 42 (+82.61%)
Mutual labels:  mobx
isomorphic-react-with-mobx
React + MobX + React-Router + Express
Stars: ✭ 52 (+126.09%)
Mutual labels:  mobx
the movie app open source
🎬 an app that lists movies in theaters and that will be released, and their respective actors using the api of the movie database, made with Flutter using Modular and MobX
Stars: ✭ 29 (+26.09%)
Mutual labels:  mobx
wizard
🍳Wizardoc is a WEBAPP for managing documents and knowledge.
Stars: ✭ 57 (+147.83%)
Mutual labels:  mobx
mobx-wxapp
在小程序中使用mobx
Stars: ✭ 54 (+134.78%)
Mutual labels:  mobx
mutable
State containers with dirty checking and more
Stars: ✭ 32 (+39.13%)
Mutual labels:  mobx
ecommerce-react-native
The ideal starter kit / app script with all the needed UI elements alongwith MobX and NativeBase to build your iOS and Android e-commerce app like Mona / JackThreads / Canopy / Flipp
Stars: ✭ 86 (+273.91%)
Mutual labels:  mobx
public-ol-native-template
OrangeLoops React-Native Project Boilerplate
Stars: ✭ 37 (+60.87%)
Mutual labels:  mobx
WebMIDICon
🎹🥁 My MIDI instruments!
Stars: ✭ 60 (+160.87%)
Mutual labels:  mobx
dva-vue
🌱 Vue and dva-core based
Stars: ✭ 34 (+47.83%)
Mutual labels:  dva
elastic-composer
Client-side Elasticsearch query generator and executor. Filter fields, find search suggestions, and paginate query results for your indicies using a simple, reactive, and high-level API
Stars: ✭ 14 (-39.13%)
Mutual labels:  mobx
hooksy
Simple app state management based on react hooks
Stars: ✭ 58 (+152.17%)
Mutual labels:  mobx
mall-by-react
一个react商城客户端和egg服务端
Stars: ✭ 22 (-4.35%)
Mutual labels:  dva
YugiohCards
Yugioh Cards Sample App using MobX, Provider, and Chopper
Stars: ✭ 31 (+34.78%)
Mutual labels:  mobx
mobx-react-intl
A connector between mobx-react and react-intl
Stars: ✭ 32 (+39.13%)
Mutual labels:  mobx
ngx-loader-indicator
Awesome loader for angular applications. No wrappers only you elements
Stars: ✭ 44 (+91.3%)
Mutual labels:  loading

mobx-loading

参考了 dva-loading 的思路,基于 mobx 实现了用于监控各个 model 和 effect 加载状态的组件

Installation

npm install --save mobx-loading

Usage

1.使用装饰器监控相关的 action

import {action} from 'mobx'
import {loading} from 'mobx-loading'

class User {
    
    // .... some things
    
    @loading
    @action
    fetchUser = () => {
        // ...do some things
        // 返回一个 Promise 对象
        return Promise;
    }
    
    @loading
    @action
    fetchList = () => {
        // ...do some things
        // 也可以不返回 Promise 对象
    }
    
    @loading('user')
    @action
    fetchA = () => {
        // ...do some things
        // 返回一个 Promise 对象
        return Promise;
    }
    
    @loading('user/a')
    @action
    fetchB = () => {
        // ...do some things
        // 返回一个 Promise 对象
        return Promise;
    }
    
    @loading(['user', 'c'])
    @action
    fetchC = () => {
        // ...do some things
        // 返回一个 Promise 对象
        return Promise;
    }
    
    // .... some things
}

2.放入 store 中

import {loadingStore} from 'mobx-loading'

// ....

store.loading = loadingStore;

ReactDOM.render(
    <Provider {...store}>
        <App/>
    </Provider>,
    document.getElementById('root')
);

3.React 组件中应用

import {inject} from 'mobx-react';

@inject(({loading}) => {
    featchUserLoading: loading.actions['user/fetchUser'],
    featchListLoading: loading.actions['user/fetchList'],
    featchALoading: loading.actions['user/a'],
    featchBLoading: loading.actions['user/b'],
    featchCLoading: loading.actions['user/c'],
    userLoading: loading.models.user,
    globalLoading: loading.global
})
class XXX extends React.Component {
    // ....
}

License

Apache 2.0 Copyright (c) 2019

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].