Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?

JavaScript でスマートに非同期なコードを書くための Promise パターンの仕様(改良版)の邦訳です。原文(英語) お約束の文言ですが、この翻訳は間違ってるかもしれません。ご指摘・ご質問は大歓迎です。 Promise/A+ この提言はPromises/A 仕様の提言の振る舞いを明確にし、かつ事実上の標準をカバーしつつ曖昧・問題のある部分を除いたものである。 Promises/Aと同様に、この提案はPromiseの作成・解決訳注 1・棄却訳注 2の方法については言及しない。 Promises/AからPromises/A+へのすべての差分は、Promises/Aとの差分(英語)に記述してある。 1. 概要 promise は、ある時点でまだ利用できない値を表現する。 promise を利用する主な方法としてthenメソッドがある。 2. 用語 2.1. 「 promise 」とは、
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015. * Some parts of this feature may have varying levels of support. Learn moreSee full compatibilityReport feedback プロミス (Promise) は、作成された時点では分からなくてもよい値へのプロキシーです。非同期のアクションの成功値または失敗理由にハンドラーを結びつけることができます。これにより、非同期メソッドは結果の値を返す代わりに、未来のある時点で値を提供するプロミスを返すことで、同期メソッドと同じように
JavaScript Promiseの本 azu Table of Contents はじめに ....................................................................................................................... 3 書籍の目的 ........................................................................................................... 3 本書を読むにあたって ........................................................................................... 3 表記法 .....
var p = new Promise(function(fulfill, reject){ console.log("start"); fulfill(""); }); p.then(function(result){ console.log("1-1"); }).then(function(result){ console.log("1-2"); }).then(function(result){ console.log("1-3"); }); p.then(function(result){ console.log("2-1") }).then(function(result){ console.log("2-2"); }).then(function(result){ console.log("2-3"); });
@armorik83です。ちょっと一段落ついたところで、そろそろ真剣にPromiseの中身を読む必要があるなーと感じたので、そのときのメモです。 読んだ実装 今回はjakearchibald/es6-promise v2.0.1を読んでいきます。基礎知識としてJavaScript Promiseの本にも目を通しておくとよいでしょう。 サンプルソース サンプルとしてPromise本の1.3.1を若干改変して利用させてもらいました。 var Promise = require('es6-promise').Promise; function getURL(URL) { return new Promise(function (resolve, reject) { var req = new XMLHttpRequest(); req.open('GET', URL, true); req.on
ES6形式のPromiseを使うときに頻出する3つのパターン。直列パターン、並列パターン、分岐パターンを説明します。 最近、Promise周りが盛り上がっていて、reduceを使ったほうが良いとか、ライブラリがどうとか・・・いう話を聞くのですが、そもそも「ベタに書いたときにどうするのが基本なのか」という情報が見つからないので書いてみました。 直列パターン 一番良く使うのは、複数の処理を直列につなげるパターンでしょう。#1が終わってから、#2、#2が終わってから#3というパターンです。 Promise.resolve() .then(function(){ return new Promise(function(fulfilled, rejected){ asyncFunc(function(){ fulfilled(); }); }) }) .then(function(){ return
The Module Pattern is the use of closures to create, in essence, private functions that are only accessible by other functions created within that closure. Functions can be attached to an object and returned outside of that function call. This establishes a public API and only the functions defined within that public API will have access to those hidden functions. The YUI blog documents this well
At a high level, the two blocks of code shown are dramatically different in when and why they execute. They do not serve the same purpose. But they are not exclusive of each other. In fact, you can nest them in to each other if you want – although this can have some odd effects if you’re not careful. jQuery’s “DOMReady” function This is an alias to jQuery’s “DOMReady” function which executes when
Brian Cray ··· Home > Blog > Javascript > Javascript module pattern: When to use it and why Written by Brian Cray on February 23rd, 2012 There have been a few criticisms of the javascript module pattern, despite its many advantages. Take for example Jonathon Snook's “Why I don't like javascript's module pattern”. While everyone has their own style, my fear is that people, given Snook's demanding p
The module pattern is a common JavaScript coding pattern. It’s generally well understood, but there are a number of advanced uses that have not gotten a lot of attention. In this article, I’ll review the basics and cover some truly remarkable advanced topics, including one which I think is original. The Basics We’ll start out with a simple overview of the module pattern, which has been well-known
One of the shortcomings of JavaScript objects is the lack of support for private members. The ability to create private members makes external APIs more meaningful and helps keep code more manageable and DRY. The Module Pattern, pioneered by Douglas Crockford while building the YUI library, is a mechanism that allows for creating public and private members in JavaScript. This post looks at the pat
One of the shortcomings of JavaScript objects is the lack of support for private members. The ability to create private members makes external APIs more meaningful and helps keep code more manageable and DRY. The Module Pattern, pioneered by Douglas Crockford while building the YUI library, is a mechanism that allows for creating public and private members in JavaScript. This post looks at the pat
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く