meteor - Structuring session variables to minimize template rerendering -


i developing first meteor project, , code basis growing, unsure using session variables/ reactive programming approach correctly. example, let's have @ form editing blog article. before editing, use session.set("current_article", articles.findone(id)) set current article. when opening article form, populated correctly using <input type="text" name="title" value="{{article.title}}">.

but form more complicated displaying title:

enter image description here

e.g. when title or tag changes, text on right right (a generated tweet message) updates while typing. achieve this, register keyup listener sets session.set("current_article", $.extend(session.get("current_article"), {tweet: somemagictweetgeneration()})). might notice way using session variables causes rerendering whole template.

so question is: makes sense storing more complex objects (like articles) session variable? way saving form quite straightforward, causes other issues. should split session.get("current_article") session.get("current_article.title"), session.get("current_article.tweet"), ...? other best practices?

you use {{#isolate}}..{{/isolate}} blocks bits of template re-rendered , not entire thing, e.g with:

{{#isolate}}     <input type="text" name="title" value="{{article.title}}"> {{/isolate}} 

so when change article.title bits inside isolate block changed, , surrounding untouched.

you have re-render bits of dom change, idea re-render bits need redrawn.

as session variables, try storing them in manner if send out variable dom, avoid sending 1 large object , instead send pieces required template.

e.g in above might have many things used in {{article}}, use {{article.title}} in bit of code, might better use template. if know you're going use of them might use nested objects.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -