Appsoulute 이재호
@acidsound
30분 동안 Micro-Social-Networking 서비스 만들기
라이브 코딩
Reactive Programing
Rx
Meteor
E2E Encryption
Declarative Programming
PublicKey
Javascript Core
DDP
TweetNacl
Functional
Reactive Programing
Rx
Meteor
E2E Encryption
Declarative Programming
PublicKey
Javascript Core
DDP
TweetNacl
Functional
Reactive Programming이란 데이터 흐름과 변화 전파에 중점을 둔 프로그래밍 패러다임입니다. 즉, 프로그래밍 언어에서 정적 또는 동적 데이터 흐름을 쉽게 표현할 수 있어야하며 변경 사항을 데이터 흐름을 통해 자동으로 전파한다는 것을 의미합니다.
It is convenient to distinguish roughly between three kinds of computer programs. Transformational programs compute results from a given set of inputs; typical examples are compilers or numerical computation programs. Interactive programs interact at their own speed with users or with other programs; from a user point of view, a time-sharing system is interactive. Reactive programs also maintain a continuous interaction with their environment, but at a speed which is determined by the environment, not the program itself. Interactive programs work at their own pace and mostly deal with communication, while reactive programs only work in respond to external demands and mostly deal with accurate interrupt handling. Real-time programs are usually reactive. However, there are reactive programs that are not usually considered as being real-time, such as protocols, system drivers, or man-machine interface handlers.
Gérard Berry - INRIA Fr.
(aka. excel)
function 으로 맛보기 (coffee/ecma6)
a = 1
b = 2
c = a + b
c
3
a = 3
c
3
a = -> 1
b = -> 2
c = -> a() + b()
c()
3
a = -> 3
c()
5
a = ()=> 1
b = ()=> 2
c = ()=> a() + b()
c()
3
a = ()=> 3
c()
5
개 소변 훈련.
- 오줌 마려울 때 마다 짖게 한다.
- 배변 패드로 이동
Reactive JavaScript 객체
- 변경될 때 마다 알려준다.
- 변경이 일어나면 특정 명령을 실행
물론 개가 아무리 짖는 다고 해도 당신이 집에 없으면?
마찬가지로 Reactive data sources는 변경이 있을 때 마다 해당 데이터를 수신 대기함.
이 곳이 Reactive Context.
변경이 일어나면 실행하는 코드 블록을 Reactive Computation이라고 한다.
/* reactive datasource 인 ReactiveVar를 선언 */
let someValue = new ReactiveVar();
/* Reactive Computation. 변경이 일어나면 console.log에 출력 */
Tracker.autorun(()=>console.log(someValue.get()));
/* reactive datasource의 변경 */
someValue.set("Hello");
> Hello
someValue.set("Hello");
/* 변경이 일어나지 않으면 Reactive Computation도 일어나지 않는다 */
(서버 없이 클라이언트만 할 것이 아니라면)
Distributed Data Protocol
관심 주제만 들을래
ㅇㅇ 필터링 해줄께
빨대꽂기
(지속적 변경 반영)
영웅은 죽지 않아요.
지금은 상식!
(aka. 비밀채팅)
그..그렇군요;
친구에게 선의로 해준거라 암호도 안걸었지만...
SecretBox
Box
Message
Key
SymNonce
암호화
복호화
Message
SecretKey
(Privatekey)
AsymNonce
PublicKey
Message
SecretKey
(Privatekey)
AsymNonce
PublicKey
암호화
복호화
1
2
3
4
5
1
5
6
순서대로 생성하고 복사해봅니다.
Key
SymNonce
Message
SecretKey
(Privatekey)
AsymNonce
PublicKey
EncMessage
EncMessage
Message
Key
SymNonce
Message
SecretKey
(Privatekey)
AsymNonce
PublicKey
EncMessage
EncMessage
Key
사용자의 개인키 보관/복원
패스워드 변경
수신자의 인원 변경
과거 메시지 정책 등등
userA가 userB에게 암호화한 메시지를 보낸다.
client meteor
server meteor
mongoDB
sub
pKey
1. 대화방 진입
sub
pKey
sub
room
sub
room
userB
userA
client meteor
server meteor
mongoDB
2. 사용자 공개키 요청
pub
pKey
pub
room
userB
userA
client meteor
server meteor
mongoDB
3. Document key 생성
userB
userA
client meteor
server meteor
mongoDB
4. Encrypt document key
DDP MAGIC!
userB
userA
client meteor
server meteor
mongoDB
5. Document key 구조
userB
userA
client meteor
server meteor
mongoDB
6. Decrypt Document key
userB
userA
client meteor
server meteor
mongoDB
7. get Document key
userB
userA
client meteor
server meteor
mongoDB
8. message 생성
abcdefghijklmnopqrst...
userB
userA
client meteor
server meteor
mongoDB
9. Encrypt message
abcdefghijklmnopqrst...
DDP MAGIC!
userB
userA
client meteor
server meteor
mongoDB
10. Get Encrypted message
abcdefghijklmnopqrst...
abcdefghijklmnopqrst...
userB
userA
client meteor
server meteor
mongoDB
11. Decrypt message
abcdefghijklmnopqrst...
abcdefghijklmnopqrst...
userB
userA
client meteor
server meteor
mongoDB
12. Get decrypted message
abcdefghijklmnopqrst...
abcdefghijklmnopqrst...
userB
userA
아니야...
WebSocket
DDP
Rx
login packet example
method$ = WebSocketResponseObservable.filter o-> o.msg is 'result'
collection$ = WebSocketResponseObservable.filter o-> o.collection
14:44:42.660 {"msg":"method","method":"login","params":
[{"resume":"3MFpDmTtUXXkmKR5JJ0OUJODb_O19BzFXcLRu0JIqmd"}]
,"id":"1"}
14:44:42.827 a {"msg":"added","collection":"users","id":"pJdkcRjHTGmKzE9hv"}
14:44:42.829 a {"msg":"changed","collection":"users","id":"pJdkcRjHTGmKzE9hv",
"fields":{
"emails":[{"address":"jhee@appsoulute.com","verified":false}]
}}
14:44:42.830 a {"msg":"updated","methods":["1"]}
14:44:42.842 a {"msg":"result","id":"1","result":{
"id":"pJdkcRjHTGmKzE9hv",
"token":"3MFpDmTtUXXkmKR5JJ0OUJODb_O19BzFXcLRu0JIqmd",
"tokenExpires":{"$date":1484372528136}
}}
RPC (Remote Procedure Call) 한 뒤 callback을 기다리지 않음
Meteor server에서 내려주는 data stream에만 반응
Application Structure
LoginView
RxMeteor
ProfileView
MessagesView
methodObservable
collectionObservable
ㄴ usersObservable
ㄴ messagesObservable
subscribeObservable
logoutMethodCall
changePasswordMethodCall
usersSubscribe
loginMethodCall
signUpMethodCall
usersSubscribe
messagesSubscribe
usersSubscribe
sendMessageMethodCall
/* login Method call */
{"msg":"method","method":"login","params":[
{"user":{"username":"admin"},"password":
{"digest":"ㄹㄹㄹㄹ","algorithm":"sha-256"}}],
"id":"1"}
/* result */
{"msg":"result","id":"1","result":{
"id":"kx4SooGR5avtZDWJN",
"token":"ZMUvf03-buGVnblochaafOi1-BCrGcIoCMf9Buo9l4p",
"tokenExpires":{"$date":1488373375267}
}}
/* Logout method call */
{"msg":"method","method":"logout","params":[],"id":"2"}
/* subscribed collection */
{"msg":"removed","collection":"users","id":"kx4SooGR5avtZDWJN"}
/* result of method */
{"msg":"method","method":"logout","params":[],"id":"2"}
validation
연타방지
중복방지
State Store - reduce
State Store - reduce
오늘의 나는 태어날 때의 나부터
어제의 나까지 리듀스 한 것
Serialize
1st start
2nd start
1st end
3rd start
2nd end
3rd end
Serialize (10단콤보!)
1st start
1st end
2nd start
2nd end
3rd start
3rd end
full-stack reactive javascript platform
full-stack reactive javascript platform
An API for asynchronous programming
with observable streams
full-stack reactive javascript platform
An API for asynchronous programming
with observable streams
https://www.facebook.com/groups/meteorschool/
Meteor school
https://www.facebook.com/groups/reactivexLab/
ReactiveX Lab