Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rsvp.js
Commits
c9188498
Commit
c9188498
authored
Sep 24, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #118 from rjackson/add_hash_to_readme
Add `hash()` to README.
parents
3987a459
760da40b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
README.md
README.md
+25
-0
No files found.
README.md
View file @
c9188498
...
@@ -168,6 +168,31 @@ RSVP.all(promises).then(function(posts) {
...
@@ -168,6 +168,31 @@ RSVP.all(promises).then(function(posts) {
});
});
```
```
## Hash of promises
If you need to reference many proises at once (like
`all()`
), but would like
to avoid encoding the actual promise order you can use
`hash()`
. If you pass
an object literal (where the values are promises) to the
`hash()`
method it will
return a new promise that will be fulfilled when all of the promises have been
fulfilled; or rejected immediately if any promise is rejected.
The key difference to the
`all()`
function is that both the fulfillment value
and the argument to the
`hash()`
function are object literals. This allows
you to simply reference the results directly off the returned object without
having to remember the initial order like you would with
`all()`
.
```
javascript
var
promises
=
{
posts
:
getJSON
(
"
/posts.json
"
),
users
:
getJSON
(
"
/users.json
"
)
};
RSVP
.
hash
(
promises
).
then
(
function
(
results
)
{
console
.
log
(
results
.
users
)
// print the users.json results
console
.
log
(
results
.
posts
)
// print the posts.json results
});
```
## TaskJS
## TaskJS
The
[
TaskJS
](
http://taskjs.org/
)
library makes it possible to take
The
[
TaskJS
](
http://taskjs.org/
)
library makes it possible to take
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment