기본 콘텐츠로 건너뛰기

9월, 2013의 게시물 표시

Meteor 에서 #constant를 사용하여 collection이 바뀌어도 특정 블록을 유지하기.

meteor는 collection을 기반으로 움직인다. 즉 collection이 변화가 있으면 해당하는 부분의 렌더링을 부분적으로 다시 하는데 고맙게도 preserve-input 이라는 패키지를 기본적으로 사용하여 전체를 다 로딩하지 않게끔 하고 있다. <head>   <title>replyExample</title> </head> <body>   {{> Posts}} </body> <template name="Posts">   <ul>     {{#each posts}}     <li>       {{message}}     </li>     {{/each}}   </ul>   <input type="text" class="newPost"/> </template> 최소한으로 컬렉션을 표시하는 html은 이런 형태일 것이다. @Posts = new Meteor.Collection "posts" if Meteor.isClient   Template.Posts.posts = ->     Posts.find {} .coffee의 내용은 이렇게 되겠지. 하지만 재귀적으로 글>댓글 형식으로 구현할 경우 다소 문제가 된다. <head>   <title>replyExample</title> </head> <body>   {{> Posts}} </body> <template name="Posts">   <ul>     {{#each posts}}     <li>       {{message}}  

Meteor의 Login유지 방식

역시 마루타는 atmosphere이다. 한번 로그인 한 사이트에 갈때마다 여러번 로그인 하는 건 세련되지 않다. 어떤식으로 Meteor에서 로그인 유지를 하는지 보자. 잡았다 요놈! Local Storage에 저장한다. 이게 Session 객체인지 Local Storage를 삭제하니까 실시간으로 로그아웃이 해제된다 + _+)!!! Meteor.loginToken으로 저장하고 확인하는구나. https://github.com/meteor/meteor/blob/devel/packages/accounts-base/localstorage_token.js 내용을 보니 localStroage에 대한 fallback( https://github.com/meteor/meteor/blob/devel/packages/localstorage/localstorage.js )을 따로 만들어 놓았다. 켁, 소스를 보니 IE일 경우 userData를 사용하네! http://msdn.microsoft.com/en-us/library/ms533007(v=vs.85).aspx 관련 내용 링크.