LoginSignup
2
2

More than 5 years have passed since last update.

Deferred化された関数を定義するイディオム

Posted at
class DummyRequest
  fetch: (url) -> $.Deferred (d) =>
    setTimeout =>
      d.resolve error: null
    , 1000

Pros

  • 関数定義を見た瞬間Deferred化された関数であることがわかる。
  • 無駄な変数定義がなく綺麗で短い

Cons

  • d.promise() してない。外部からresolveやrejectを叩かれる可能性がある。
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2