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
760da40b
Commit
760da40b
authored
Sep 24, 2013
by
Robert Jackson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `hash()` to README.
parent
3987a459
Changes
1
Hide 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 @
760da40b
...
...
@@ -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
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