タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

デザインパターンとPromisesに関するefclのブックマーク (2)

  • Promise Anti-patterns – Tao of Code

    Promises are very simple once you get your head around them, but there are a few gotchas that can leave you with your head scratching. Here are a few that got me. Nested Promises You get a whole bundle of promises nested in eachother: loadSomething().then(function(something) { loadAnotherthing().then(function(another) { DoSomethingOnThem(something, another); }); }); The reason you’ve done this is

    efcl
    efcl 2014/02/23
    Promisesのアンチパターンについて。 ネストしたpromise、 例外を`catch`できないpromise、配列の中身に対してそれぞれ非同期処理するケース、分岐とpromise、過剰なエラーハンドリング、無駄なpromise
  • The Revealing Constructor Pattern

    I want to document an interesting pattern we’ve seen emerge in some recent web platform specs, including promises and streams. I’m calling it the revealing constructor pattern. The Promises Example Let’s take the case of promises first, since that may be familiar. You can construct a new promise like so: var p = new Promise(function (resolve, reject) { // Use `resolve` to resolve `p`. // Use `reje

    efcl
    efcl 2014/02/15
    ES6 Promises等で使われてるコンストラクタむき出しパターンについて。 `constructor` プロパティや`[[prototype]]` が綺麗に出来る点や`class` syntaxを使った継承との相性が良い。
  • 1