- 준비
ddp 라이브러리 추가
$ meteor add ddp - 외부 DDP 연결
extDDP = DDP.connect("http://externalhost.com:4100"); - Collection 연결
Posts = new Mongo.Collection('posts', extDDP);
2,3 과정은 client 에서 가장 먼저 실행되도록 client/lib 디렉토리 안에 넣는 것을 추천 - 기존 연결을 외부 DDP로 대치
Meteor.connection = extDDP;
ex) 활용예
Meteor.connection = extDDP;
Meteor.loginWithPassword(login.valiu, password.value);
Meteor.startup 같은 곳에서 사용하면 좋음.
만일 login을 그냥 사용하려면
expDDP.call('login', .... ); 형태로 사용하여야함. - Subscribe 사용
onCreated 시점에 this.subscribe 대신 DDP 객체의 subscribe를 사용
Template.postView.onCreated(function() {
extDDP.subscribe("getPosts", { searchWord: 'blahblah' });
}); - Helper 사용
3번처럼 했다면 그냥 똑같이 사용
Tempalte.postView.helpers({
"posts": function() {
return Posts.find({});
}
}); - Method 사용
Template.postInput.events({
"submit": function(e) {
expDDP.call('addPost', inputText.value', function(error, result) {
/* do something */
});
e.preventDefault();
}
});
http://superuser.com/a/660072 글 참조. OS X 에서 tmux 사용시 나눠놓은 pane 크기 조정할 때 원래는 ctrl+b, ctrl+↑←→↓ 로 사이즈를 조정하는데 기본 터미널 키 입력이 조금 문제가 있다. 키 매핑을 다시 하자 Preferences(cmd+,) > Profile > 변경하고자 하는 Theme 선택 > Keyboards 로 들어가서 \033[1;5A \033[1;5B \033[1;5C \033[1;5D 를 순서대로 ↑↓→←순으로 매핑이 되도록 하면 된다. +를 누르고 Key에 해당 화살표키와 Modifier에 ctrl 선택 한 후 <esc>, [, 1, ;, 5 까지 한키 한키 입력 후 A,B,C,D를 써준다. 잘못 입력했을 땐 당황하지 말고 Delete on character 버튼을 눌러 수정하도록 하자. 그리고 다시 tmux에서 ctrl+b, ctrl+↑←→↓로 사이즈를 조절해보자. 잘 된다.
댓글
댓글 쓰기