下一代 React 数据库 WatermelonDB

码农软件 · 软件分类 · React 开源项目 · 2019-04-27 21:58:45

软件介绍

WatermelonDB,下一代 React 数据库,可构建功能强大的 React 和 React Native 应用程序,可在保持快速的同时从数百个记录扩展到数万个记录。

WatermelonDB 是一种在 React Native 和 React Web 应用中处理用户数据的新方法。它针对在 React/React Native 中构建复杂应用进行优化,其首要目标是提高实际性能。简单来说,就是保证的的应用必须快速启动。

当你开始扩展到数千或数万个数据库记录时,会发现对应用的启动速度有很大影响,尤其是在速度较慢的 Android 设备上。WatermelonDB 通过惰性(lazy)来解决问题 —— 除非有要求,否则不加载。而且由于所有查询都是直接以单独的线程在稳定的 SQLite 数据库上执行的,所以即使是在较慢的 Android 设备上,多数查询也会在不到1毫秒的时间内解析,即使有 10,000 条记录!

Usage

首先,定义模型

class Post extends Model {
  @field('name') name
  @field('body') body
  @children('comments') comments
}

class Comment extends Model {
  @field('body') body
  @field('author') author
}

然后,将组件与数据连接:

const Comment = ({ comment }) => (
  <View style={styles.commentBox}>
    <Text>{comment.body} — by {comment.author}</Text>
  </View>
)

// This is how you make your app reactive! ✨
const enhance = withObservables(['comment'], ({ comment }) => ({
  comment: comment.observe()
}))
const EnhancedComment = enhance(Comment)

即可进行渲染

const Post = ({ post, comments }) => (
  <View>
    <Text>{post.name}</Text>
    <Text>Comments:</Text>
    {comments.map(comment =>
      <Comment key={comment.id} comment={comment} />
    )}
  </View>
)

const enhance = withObservables(['post'], ({ post }) => ({
  post: post.observe(),
  comments: post.comments.observe()
}))

本文地址:https://www.codercto.com/soft/d/4532.html

计算机程序设计艺术 第2卷 半数值算法(第3版)(英文影印版)

计算机程序设计艺术 第2卷 半数值算法(第3版)(英文影印版)

(美)Donald E.Knuth / 清华大学出版社 / 2002-09-01 / 83.0

计算机程序设计艺术:英文版(第2卷 半数值算法),ISBN:9787302058151,作者:(美)Donald E. Knuth著一起来看看 《计算机程序设计艺术 第2卷 半数值算法(第3版)(英文影印版)》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

SHA 加密
SHA 加密

SHA 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具