ngToronto Angular Meetup notes – January 2015

Promise-based architecture by Yuri


  • 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. 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 & will provide beer and pizza.First Talk: Promise Based Architecture – Yuri Takhteyev CTO of  (@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 →

November 27 ngToronto meetup

Shopify hosted ngToronto

How not to die moving from Angular 1.x to 2 with Nick and Yuri from

  • J2EE, Rails, Python, ActionScript all had unpredictable, large shifts over the years. This is no surprise!

  • Angular may change, but plain js is a good starting place for future browser technologies

  • Soul of angular is DRY, structure, testability, which are portable concepts

  • Angular 2 is a 3 year plan. They early announcement prevents us from being blindsided by change, but it is freaking people out. The alternative to no change is standardize and stick with IE6 like banks did for many years

  • Good news: lots of discussions on design of Angular 2 are online and public, so anyone can catch up on how and why things are changing

  • Look for Nick’s matrix outlining changes in scope, controllers, DI, messaging.

Easy ways to prepare, best practices for today.

  • Nested scope? No Says Yuri! Avoid. Use controller as syntax

  • Always put directives in isolated scope

  • Put as much stuff in services as possible, because services are modules with DI. Then could swap Angular’s DI with something else in the future. See Rangle’s Nebular project

Harder ways to prepare

  • Use more plain js (no dependencies other than a browser environment) and export objects as modules to use inside of Angular 1.x services

  • Yuri is thinking about running components of a large app in an iframe to sandbox, see multi-framework-app on Github. Each iframe can run a different version of Angular, or another framework entirely. iframes can communicate with each other over a simple API so they can all be integrated together

ES6 with Matias Niemelä