51
Introduction to Meteor & React 9/16 React 讀讀讀

Introduction to Meteor & React

  • Upload
    max-li

  • View
    252

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Introduction to Meteor & React

Introduction to Meteor & React

9/16 React 讀書會

Page 3: Introduction to Meteor & React

What is Meteor ?

Code Demo

How is behind Meteor ?

The Plight of Meteor

The Future of Meteor

Company in Taiwan

Resources

What We’ll Cover

Page 4: Introduction to Meteor & React

What is Meteor ?

Page 5: Introduction to Meteor & React

A full-stack, open source platform for building web and mobile apps in JavaScript

DDP Subscribe to changes in the database

MiniMongo Client-side in-memory mongodb

Tracker Rerun function when data changes

Blaze Reactive HTML templates

Page 6: Introduction to Meteor & React

store.subscribe()

DDP

MiniMongo

Tracker

Store

X

2012 2015

Page 7: Introduction to Meteor & React

Data Flow

Page 8: Introduction to Meteor & React

Atmosphere - 1

Page 10: Introduction to Meteor & React

Code Demo

Page 11: Introduction to Meteor & React

meteor create messenger

Messenger App

Page 12: Introduction to Meteor & React

File structure

Page 13: Introduction to Meteor & React

npm install --save react react-dom

Defining views with React components

Page 14: Introduction to Meteor & React

Defining views with React componentshttps://goo.gl/g58hDP

Page 15: Introduction to Meteor & React

Storing messages in a collection - 1

Create messages collection

Page 16: Introduction to Meteor & React

File structure

Page 17: Introduction to Meteor & React

Load messages collection on the server

Storing messages in a collection - 2

meteor mongo

db.messages.insert( { username: " 罗胖 ", text: " 逻辑思维👍 ", createdAt: new Date()} )

db.messages.find({})

Page 18: Introduction to Meteor & React

Connect Minimongo with React

Storing messages in a collection - 3

meteor npm install --save react-addons-pure-render-mixinmeteor add react-meteor-data

Page 19: Introduction to Meteor & React

Storing messages in a collection - 4

Messages.find().fetch()

https://goo.gl/A6IpKF

Page 20: Introduction to Meteor & React

meteor mongo

db.messages.insert( { username: "TJ", text: "DDP", createdAt: new Date()} )

Storing messages in a collection - 5

DDP - Subscribe to changes in the database

Page 21: Introduction to Meteor & React

DDP

Page 22: Introduction to Meteor & React

Defining methods - 1

Call by both sever & client side

Page 23: Introduction to Meteor & React

Defining methods - 2

Meteor.methods({ 'messages.insert': text => { const username = 'Anonymous'

Messages.insert({ username, text, createAt: new Date() }) }})

Page 24: Introduction to Meteor & React

Defining methods - 2

import '../../api/messages/methods'

Meteor.call('messages.insert', this.state.value)

import '../../api/messages/methods'

Backend

Frontend

Page 25: Introduction to Meteor & React

Latency Compensation - 1

import '../../api/messages/methods'

Meteor.call('messages.insert', this.state.value)

Frontend

Page 26: Introduction to Meteor & React

Recall File structure

Call by both sever & client side

Page 27: Introduction to Meteor & React

Latency Compensation -1

Page 28: Introduction to Meteor & React

Latency Compensation - 2not import method to front-end

if (Meteor.isServer) { const d1 = Date.now() while (Date.now() < d1 + 10000) { // do nothing }}

// import '../../api/messages/methods'

Page 29: Introduction to Meteor & React

Latency Compensation - 3

import '../../api/messages/methods'

import method to front-end

meteor mongo

db.messages.find()

Page 30: Introduction to Meteor & React

Latency Compensation -4

Page 31: Introduction to Meteor & React

Adding user accounts - 1

https://goo.gl/nHB5n8

Page 32: Introduction to Meteor & React

Adding user accounts - 2

Meteor.userId()

Meteor.user().username

Page 33: Introduction to Meteor & React

Demo Chat room

db.messages.drop()meteor mongo

Page 35: Introduction to Meteor & React

How is behind Meteor ?

Page 36: Introduction to Meteor & React

Meteor Development Group

Page 37: Introduction to Meteor & React

The Plight of Meteor

Page 38: Introduction to Meteor & React

Meteor ~= React + Redux + Backend

Express, Koa, Go, Scala

Page 39: Introduction to Meteor & React

The Future of Meteor

Page 40: Introduction to Meteor & React
Page 41: Introduction to Meteor & React

Meteor 1.5

DDP

MiniMongo

Tracker

Blaze

Redux

Apollo/GraphQL

Redux

React

Page 42: Introduction to Meteor & React

Recall Meteor Development Group

Page 43: Introduction to Meteor & React

Meteor

React + Redux + GraphQL + Socket.io Backend

===

Meteor 1.5

Page 44: Introduction to Meteor & React
Page 45: Introduction to Meteor & React

Meteor

React + Redux + GraphQL + Socket.io Backend

===

Meteor 1.5

整合資源形成平台 (Platform)

Page 46: Introduction to Meteor & React

Meteor 1.5

Page 47: Introduction to Meteor & React

Company in Taiwan

Page 49: Introduction to Meteor & React

Resources

Page 51: Introduction to Meteor & React