by

ngToronto Angular Meetup notes – January 2015

Promise-based architecture by Yuri

slides

  • think of promises as wrappers around uncertain results
  • promises separate defining a request and response handler (callback) at the same time.
  • writing functions that accept promises as arguments and return promises, you can make something that almost looks like synchronous code

Check the table in the presentation for useful definitions of promise behaviour (“when the callback…”)

Avoid $q.defer, Denodify instead

Trivial Promises

  • $q.when(x) returns an ok promise
  • $q.reject(e) returns a rejected promise

Stay consistent

  • functions should never ‘sometimes’ return a promise. Always return a promise, or never return a promise. See $q.when and $q.reject
  • return a promise if you aren’t sure whether code will eventually be async or not async

Avoid Optimistic Code

  • optimistic code is code where you assume that data will eventually be loaded
  • ask for a promise instead, even if you think the data loaded already

Neat things with promises


Hexo + AngularJS by Matias

Slides and Code

Hexo is:

Static sites are good because:

  • Host on AWS S3 (cheap and fast) and CloudFlare (even faster!)
  • You get a local copy of your site that’s always up to date by default. Your writing happens locally, and is saved in version control

Hexo is good because:

  • Hexo rebuilds pages and sites quickly, hexo server command watches for content changes and live-reloads them in your browser while you are writing posts
  • posts are written in markdown with a small YAML header
  • your content can live as files in a Git repo, and custom theme in another Git repo (possibly a private repo)
  • templates use common js templating formats – ejs, jade
  • uses excellent tools like Warehouse.js
  • supports custom pages too (not just posts)

How do I handle dynamic behaviour without a backend?

3rd party services and more JS!

Angular idea

How about capturing all internal link clicks using an Angular directive, and replacing the default behaviour with pushstate, an AJAX call to load the requested page, and an animation to load the content into the current page? That gives you even faster page loads and room to animate content coming and going. Yearofmoo.com is doing this now.

AngularJS Service Architecture

Wednesday, Jan 28, 2015, 7:00 PM

Mozilla Community Space
366 Adelaide St. W, Suite 500 Toronto, ON

180 Members Went

Join us for the first AngularJS Toronto meetup of 2015! Mozilla will host us and Cetaris & rangle.io will provide beer and pizza.First Talk: Promise Based Architecture – Yuri Takhteyev CTO of rangle.io  (@qaramazov)Yuri is a former faculty member at the University of Toronto, and a published author, whose interests span software architecture and …

Check out this Meetup →