# mobx-miniprogram
可用于小程序的 MobX 构建版本。基于 MobX 4 (因为 iOS 9 不支持 MobX 5 )。
`npm install mobx-miniprogram --save`
以下是 MobX 原本的 README 。
<img src="docs/mobx.png" alt="logo" height="120" align="right" />
# MobX
_Simple, scalable state management_
[![CircleCI](https://circleci.com/gh/mobxjs/mobx/tree/mobx4-master.svg?style=svg)](https://circleci.com/gh/mobxjs/mobx/tree/mobx4-master)
[![Coverage Status](https://coveralls.io/repos/mobxjs/mobx/badge.svg?branch=master&service=github)](https://coveralls.io/github/mobxjs/mobx?branch=master)
[![Join the chat at https://gitter.im/mobxjs/mobx](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mobxjs/mobx?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Discuss MobX on Hashnode](https://hashnode.github.io/badges/mobx.svg)](https://hashnode.com/n/mobx)
[![OpenCollective](https://opencollective.com/mobx/backers/badge.svg)](#backers)
[![OpenCollective](https://opencollective.com/mobx/sponsors/badge.svg)](#sponsors)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
MobX is proudly sponsored by Mendix, Coinbase, Facebook Open Source and many [individual sponsors](#backers)
<img src="docs/mendix-logo.png" align="center" width="100" title="Mendix" alt="Mendix" /> <img src="docs/coinbase.jpeg" align="center" width="100" title="Coinbase" alt="Coinbase" /> <img src="docs/fbos.jpeg" align="center" width="100" title="Facebook Open Source" alt="Facebook Open Source" />
# Installation
* Installation: `npm install mobx --save`. React bindings: `npm install mobx-react --save`. To enable ESNext decorators (optional), see below.
* CDN:
- https://unpkg.com/mobx/lib/mobx.umd.js
- https://cdnjs.com/libraries/mobx
## Translations
* [中文](http://cn.mobx.js.org)
## Getting started
* <i><a style="color: white; background:green;padding:5px;margin:5px;border-radius:2px" href="https://egghead.io/courses/manage-complex-state-in-react-apps-with-mobx">Egghead.io course</a></i>
* [Ten minute, interactive MobX + React tutorial](https://mobxjs.github.io/mobx/getting-started.html)
* [Official MobX 4 documentation and API overview](https://mobxjs.github.io/mobx/refguide/api.html) ([MobX 3](https://github.com/mobxjs/mobx/blob/54557dc319b04e92e31cb87427bef194ec1c549c/docs/refguide/api.md), [MobX 2](https://github.com/mobxjs/mobx/blob/7c9e7c86e0c6ead141bb0539d33143d0e1f576dd/docs/refguide/api.md))
* Videos:
* [ReactNext 2016: Real World MobX](https://www.youtube.com/watch?v=Aws40KOx90U) - 40m [slides](https://docs.google.com/presentation/d/1DrI6Hc2xIPTLBkfNH8YczOcPXQTOaCIcDESdyVfG_bE/edit?usp=sharing)
* [Practical React with MobX](https://www.youtube.com/watch?v=XGwuM_u7UeQ). In depth introduction and explanation to MobX and React by Matt Ruby on OpenSourceNorth (ES5 only) - 42m.
* LearnCode.academy MobX tutorial [Part I: MobX + React is AWESOME (7m)](https://www.youtube.com/watch?v=_q50BXqkAfI) [Part II: Computed Values and Nested/Referenced Observables (12m.)](https://www.youtube.com/watch?v=nYvNqKrl69s)
* [Screencast: intro to MobX](https://www.youtube.com/watch?v=K8dr8BMU7-8) - 8m
* [Talk: State Management Is Easy, React Amsterdam 2016 conf](https://www.youtube.com/watch?v=ApmSsu3qnf0&feature=youtu.be) ([slides](https://speakerdeck.com/mweststrate/state-management-is-easy-introduction-to-mobx))
* [Boilerplates and related projects](http://mobxjs.github.io/mobx/faq/boilerplates.html)
* More tutorials, blogs, videos, and other helpful resources can be found on the [MobX awesome list](https://github.com/mobxjs/awesome-mobx#awesome-mobx)
## Introduction
MobX is a battle tested library that makes state management simple and scalable by transparently applying functional reactive programming (TFRP).
The philosophy behind MobX is very simple:
_Anything that can be derived from the application state, should be derived. Automatically._
which includes the UI, data serialization, server communication, etc.
<img alt="MobX unidirectional flow" src="docs/flow.png" align="center" />
React and MobX together are a powerful combination. React renders the application state by providing mechanisms to translate it into a tree of renderable components. MobX provides the mechanism to store and update the application state that React then uses.
Both React and MobX provide optimal and unique solutions to common problems in application development. React provides mechanisms to optimally render UI by using a virtual DOM that reduces the number of costly DOM mutations. MobX provides mechanisms to optimally synchronize application state with your React components by using a reactive virtual dependency state graph that is only updated when strictly needed and is never stale.
## Core concepts
MobX has only a few core concepts. The following snippets can be tried online using [codesandbox example](https://codesandbox.io/s/v3v0my2370).
### Observable state
<i><a style="color: white; background:green;padding:5px;margin:5px;border-radius:2px" href="https://egghead.io/lessons/javascript-sync-the-ui-with-the-app-state-using-mobx-observable-and-observer-in-react">Egghead.io lesson 1: observable & observer</a></i>
MobX adds observable capabilities to existing data structures like objects, arrays and class instances.
This can simply be done by annotating your class properties with the [@observable](http://mobxjs.github.io/mobx/refguide/observable-decorator.html) decorator (ES.Next).
```javascript
import { observable } from "mobx"
class Todo {
id = Math.random();
@observable title = "";
@observable finished = false;
}
```
Using `observable` is like turning a property of an object into a spreadsheet cell.
But unlike spreadsheets, these values can be not only primitive values, but also references, objects and arrays.
If your environment doesn't support decorator syntax, don't worry.
You can read [here](http://mobxjs.github.io/mobx/best/decorators.html) about how to set them up.
Or you can skip them altoghether, as MobX can be used fine without decorator _syntax_, by leveraging the _decorate_ utility.
Many MobX users do prefer the decorator syntax though, as it is slightly more concise.
```javascript
import { decorate, observable } from "mobx"
class Todo {
id = Math.random();
title = "";
finished = false;
}
decorate(Todo, {
title: observable,
finished: observable
})
```
### Computed values
<i><a style="color: white; background:green;padding:5px;margin:5px;border-radius:2px" href="https://egghead.io/lessons/javascript-derive-computed-values-and-manage-side-effects-with-mobx-reactions">Egghead.io lesson 3: computed values</a></i>
With MobX you can define values that will be derived automatically when relevant data is modified.
By using the [`@computed`](http://mobxjs.github.io/mobx/refguide/computed-decorator.html) decorator or by using getter / setter functions when using `(extend)Observable` (Of course, you can use `decorate` here again as alternative to the `@` syntax).
```javascript
class TodoList {
@observable todos = [];
@computed get unfinishedTodoCount() {
return this.todos.filter(todo => !todo.finished).length;
}
}
```
MobX will ensure that `unfinishedTodoCount` is updated automatically when a todo is added or when one of the `finished` properties is modified.
Computations like these resemble formulas in spreadsheet programs like MS Excel. They update automatically and only when required.
### Reactions
<i><a style="color: white; background:green;padding:5px;margin:5px;border-radius:2px" href="https://egghead.io/lessons/react-write-custom-mobx-reactions-with-when-and-autorun">Egghead.io lesson 9: custom reactions</a></i>
Reactions are similar to a computed value, but instead of producing a new value, a reaction produces a side effect for things like printing to the console, making network requests, incrementally up
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
微信小程序 仿网易云音乐 (源码).zip 已获导师指导并通过的97分的高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 微信小程序 仿网易云音乐 (源码).zip 已获导师指导并通过的97分的高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。微信小程序 仿网易云音乐 (源码).zip 已获导师指导并通过的97分的高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。微信小程序 仿网易云音乐 (源码).zip 已获导师指导并通过的97分的高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。微信小程序 仿网易云音乐 (源码).zip 已获导师指导并通过的97分的高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。微信小程序 仿网易云音乐 (源码).zip 已获导师指导并通过的97分的高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。微信小程序 仿网易云音乐 (源码)
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序 仿网易云音乐 (源码).zip (1585个子文件)
mobx.js.flow 15KB
index.js 67KB
index.js 67KB
index.js 12KB
index.js 12KB
index.js 12KB
index.js 12KB
index.js 11KB
index.js 10KB
index.js 10KB
index.js 10KB
Song.js 10KB
index.js 9KB
index.js 9KB
index.js 9KB
index.js 8KB
index.js 8KB
index.js 8KB
index.js 7KB
index.js 7KB
index.js 7KB
index.js 7KB
index.js 7KB
index.js 7KB
index.js 7KB
index.js 7KB
index.js 6KB
index.js 6KB
index.js 6KB
index.js 6KB
index.js 6KB
index.js 6KB
index.js 6KB
index.js 6KB
index.js 5KB
index.js 5KB
Player.js 5KB
index.js 5KB
myInfo.js 5KB
index.js 5KB
index.js 5KB
index.js 5KB
transition.js 5KB
transition.js 5KB
AllPlaylist.js 5KB
index.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
transition.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
utils.js 4KB
utils.js 4KB
index.js 4KB
index.js 4KB
Artists.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
index.js 4KB
SearchDetail.js 4KB
index.js 4KB
index.js 3KB
index.js 3KB
home.js 3KB
index.js 3KB
index.js 3KB
index.js 3KB
utils.js 3KB
utils.js 3KB
method.js 3KB
index.js 3KB
follow.js 3KB
Comment.js 3KB
utils.js 3KB
utils.js 3KB
utils.js 3KB
index.js 3KB
index.js 3KB
index.js 3KB
index.js 3KB
index.js 3KB
dialog.js 3KB
dialog.js 3KB
index.js 3KB
index.js 3KB
index.js 3KB
toast.js 2KB
toast.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
index.js 2KB
utils.js 2KB
共 1585 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论
- m0_638296202023-11-22进去了一点反应都没有
- gm200010252023-12-04#运行出错 #上传者态度恶劣 #标题与内容不符 #毫无价值
- 徐必成睡醒了吗2023-11-29资源质量不错,和资源描述一致,内容详细,对我很有用。
- 2201_759759952023-12-27超级好的资源,很值得参考学习,对我启发很大,支持!
- 2201_758863742023-12-11怎么能有这么好的资源!只能用感激涕零来形容TAT...
不安分的小女孩
- 粉丝: 9276
- 资源: 2015
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功