Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Hardik Juneja
jio-main
Commits
8e55feab
Commit
8e55feab
authored
Mar 04, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RSVP library updated
parent
f42a2f78
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
160 additions
and
32 deletions
+160
-32
lib/rsvp/rsvp-custom.amd.js
lib/rsvp/rsvp-custom.amd.js
+80
-16
lib/rsvp/rsvp-custom.js
lib/rsvp/rsvp-custom.js
+80
-16
No files found.
lib/rsvp/rsvp-custom.amd.js
View file @
8e55feab
...
...
@@ -59,11 +59,16 @@ define("rsvp/all",
};
}
function
cancelAll
(
rejectionValue
)
{
reject
(
rejectionValue
);
canceller
();
}
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
promise
=
promises
[
i
];
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
)
{
promise
.
then
(
resolver
(
i
),
reject
,
notifier
(
i
));
promise
.
then
(
resolver
(
i
),
cancelAll
,
notifier
(
i
));
}
else
{
resolveAll
(
i
,
promise
);
}
...
...
@@ -506,6 +511,9 @@ define("rsvp/promise",
var
hasCallback
=
isFunction
(
callback
),
value
,
error
,
succeeded
,
failed
;
if
(
promise
.
isFulfilled
)
{
return
;
}
if
(
promise
.
isRejected
)
{
return
;
}
if
(
hasCallback
)
{
try
{
value
=
callback
(
event
.
detail
);
...
...
@@ -623,6 +631,11 @@ define("rsvp/promise",
then
=
value
.
then
;
if
(
isFunction
(
then
))
{
if
(
isFunction
(
value
.
on
))
{
value
.
on
(
'
promise:notified
'
,
function
(
event
)
{
notify
(
promise
,
event
.
detail
);
});
}
promise
.
on
(
'
promise:cancelled
'
,
function
(
event
)
{
if
(
isFunction
(
value
.
cancel
))
{
value
.
cancel
();
...
...
@@ -657,6 +670,8 @@ define("rsvp/promise",
function
fulfill
(
promise
,
value
)
{
config
.
async
(
function
()
{
if
(
promise
.
isFulfilled
)
{
return
;
}
if
(
promise
.
isRejected
)
{
return
;
}
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isFulfilled
=
true
;
promise
.
fulfillmentValue
=
value
;
...
...
@@ -665,6 +680,8 @@ define("rsvp/promise",
function
reject
(
promise
,
value
)
{
config
.
async
(
function
()
{
if
(
promise
.
isFulfilled
)
{
return
;
}
if
(
promise
.
isRejected
)
{
return
;
}
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
rejectedReason
=
value
;
...
...
@@ -699,25 +716,41 @@ define("rsvp/queue",
ResolvedQueueError
.
prototype
.
constructor
=
ResolvedQueueError
;
var
Queue
=
function
()
{
var
promis
e
=
this
,
var
queu
e
=
this
,
promise_list
=
[],
promise
,
fulfill
,
reject
;
reject
,
notify
,
resolved
;
if
(
!
(
this
instanceof
Queue
))
{
return
new
Queue
();
}
function
canceller
()
{
for
(
var
i
=
0
;
i
<
promise_list
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
2
;
i
++
)
{
promise_list
[
i
].
cancel
();
}
}
Promise
.
apply
(
promise
,
[
function
(
done
,
fail
)
{
fulfill
=
done
;
reject
=
fail
;
},
canceller
]);
promise
=
new
Promise
(
function
(
done
,
fail
,
progress
)
{
fulfill
=
function
(
fulfillmentValue
)
{
if
(
resolved
)
{
return
;}
queue
.
isFulfilled
=
true
;
queue
.
fulfillmentValue
=
fulfillmentValue
;
resolved
=
true
;
return
done
(
fulfillmentValue
);
};
reject
=
function
(
rejectedReason
)
{
if
(
resolved
)
{
return
;}
queue
.
isRejected
=
true
;
queue
.
rejectedReason
=
rejectedReason
;
resolved
=
true
;
return
fail
(
rejectedReason
);
};
notify
=
progress
;
},
canceller
);
promise_list
.
push
(
delay
());
promise_list
.
push
(
promise_list
[
0
].
then
(
function
()
{
...
...
@@ -727,19 +760,32 @@ define("rsvp/queue",
}
}));
promise
.
push
=
function
(
done
,
fail
)
{
queue
.
cancel
=
function
()
{
if
(
resolved
)
{
return
;}
resolved
=
true
;
promise
.
cancel
();
promise
.
fail
(
function
(
rejectedReason
)
{
queue
.
isRejected
=
true
;
queue
.
rejectedReason
=
rejectedReason
;
});
};
queue
.
then
=
function
()
{
return
promise
.
then
.
apply
(
promise
,
arguments
);
};
queue
.
push
=
function
(
done
,
fail
,
progress
)
{
var
last_promise
=
promise_list
[
promise_list
.
length
-
1
],
next_promise
;
if
(
this
.
isRejected
||
this
.
isFulfill
ed
)
{
if
(
resolv
ed
)
{
throw
new
ResolvedQueueError
();
}
next_promise
=
last_promise
.
then
(
done
,
fail
);
next_promise
=
last_promise
.
then
(
done
,
fail
,
progress
);
promise_list
.
push
(
next_promise
);
// Handle pop
promise_list
.
push
(
next_promise
.
then
(
function
(
fulfillmentValue
)
{
last_promise
=
next_promise
.
then
(
function
(
fulfillmentValue
)
{
promise_list
.
splice
(
0
,
2
);
if
(
promise_list
.
length
===
0
)
{
fulfill
(
fulfillmentValue
);
...
...
@@ -747,11 +793,19 @@ define("rsvp/queue",
return
fulfillmentValue
;
}
},
function
(
rejectedReason
)
{
if
(
!
(
promise
.
isRejected
||
promise
.
isFulfilled
))
{
promise_list
.
splice
(
0
,
2
);
if
(
promise_list
.
length
===
0
)
{
reject
(
rejectedReason
);
}
else
{
throw
rejectedReason
;
}
throw
rejectedReason
;
}));
},
function
(
notificationValue
)
{
if
(
promise_list
[
promise_list
.
length
-
1
]
===
last_promise
)
{
notify
(
notificationValue
);
}
return
notificationValue
;
});
promise_list
.
push
(
last_promise
);
return
this
;
};
...
...
@@ -787,7 +841,17 @@ define("rsvp/resolve",
function
resolve
(
thenable
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
thenable
);
if
(
typeof
thenable
===
"
object
"
&&
thenable
!==
null
)
{
var
then
=
thenable
.
then
;
if
((
then
!==
undefined
)
&&
(
typeof
then
===
"
function
"
))
{
return
then
.
apply
(
thenable
,
[
resolve
,
reject
]);
}
}
return
resolve
(
thenable
);
},
function
()
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
thenable
.
cancel
();
}
});
}
...
...
lib/rsvp/rsvp-custom.js
View file @
8e55feab
...
...
@@ -96,11 +96,16 @@ define("rsvp/all",
};
}
function
cancelAll
(
rejectionValue
)
{
reject
(
rejectionValue
);
canceller
();
}
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
promise
=
promises
[
i
];
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
)
{
promise
.
then
(
resolver
(
i
),
reject
,
notifier
(
i
));
promise
.
then
(
resolver
(
i
),
cancelAll
,
notifier
(
i
));
}
else
{
resolveAll
(
i
,
promise
);
}
...
...
@@ -543,6 +548,9 @@ define("rsvp/promise",
var
hasCallback
=
isFunction
(
callback
),
value
,
error
,
succeeded
,
failed
;
if
(
promise
.
isFulfilled
)
{
return
;
}
if
(
promise
.
isRejected
)
{
return
;
}
if
(
hasCallback
)
{
try
{
value
=
callback
(
event
.
detail
);
...
...
@@ -660,6 +668,11 @@ define("rsvp/promise",
then
=
value
.
then
;
if
(
isFunction
(
then
))
{
if
(
isFunction
(
value
.
on
))
{
value
.
on
(
'
promise:notified
'
,
function
(
event
)
{
notify
(
promise
,
event
.
detail
);
});
}
promise
.
on
(
'
promise:cancelled
'
,
function
(
event
)
{
if
(
isFunction
(
value
.
cancel
))
{
value
.
cancel
();
...
...
@@ -694,6 +707,8 @@ define("rsvp/promise",
function
fulfill
(
promise
,
value
)
{
config
.
async
(
function
()
{
if
(
promise
.
isFulfilled
)
{
return
;
}
if
(
promise
.
isRejected
)
{
return
;
}
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isFulfilled
=
true
;
promise
.
fulfillmentValue
=
value
;
...
...
@@ -702,6 +717,8 @@ define("rsvp/promise",
function
reject
(
promise
,
value
)
{
config
.
async
(
function
()
{
if
(
promise
.
isFulfilled
)
{
return
;
}
if
(
promise
.
isRejected
)
{
return
;
}
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
rejectedReason
=
value
;
...
...
@@ -736,25 +753,41 @@ define("rsvp/queue",
ResolvedQueueError
.
prototype
.
constructor
=
ResolvedQueueError
;
var
Queue
=
function
()
{
var
promis
e
=
this
,
var
queu
e
=
this
,
promise_list
=
[],
promise
,
fulfill
,
reject
;
reject
,
notify
,
resolved
;
if
(
!
(
this
instanceof
Queue
))
{
return
new
Queue
();
}
function
canceller
()
{
for
(
var
i
=
0
;
i
<
promise_list
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
2
;
i
++
)
{
promise_list
[
i
].
cancel
();
}
}
Promise
.
apply
(
promise
,
[
function
(
done
,
fail
)
{
fulfill
=
done
;
reject
=
fail
;
},
canceller
]);
promise
=
new
Promise
(
function
(
done
,
fail
,
progress
)
{
fulfill
=
function
(
fulfillmentValue
)
{
if
(
resolved
)
{
return
;}
queue
.
isFulfilled
=
true
;
queue
.
fulfillmentValue
=
fulfillmentValue
;
resolved
=
true
;
return
done
(
fulfillmentValue
);
};
reject
=
function
(
rejectedReason
)
{
if
(
resolved
)
{
return
;}
queue
.
isRejected
=
true
;
queue
.
rejectedReason
=
rejectedReason
;
resolved
=
true
;
return
fail
(
rejectedReason
);
};
notify
=
progress
;
},
canceller
);
promise_list
.
push
(
delay
());
promise_list
.
push
(
promise_list
[
0
].
then
(
function
()
{
...
...
@@ -764,19 +797,32 @@ define("rsvp/queue",
}
}));
promise
.
push
=
function
(
done
,
fail
)
{
queue
.
cancel
=
function
()
{
if
(
resolved
)
{
return
;}
resolved
=
true
;
promise
.
cancel
();
promise
.
fail
(
function
(
rejectedReason
)
{
queue
.
isRejected
=
true
;
queue
.
rejectedReason
=
rejectedReason
;
});
};
queue
.
then
=
function
()
{
return
promise
.
then
.
apply
(
promise
,
arguments
);
};
queue
.
push
=
function
(
done
,
fail
,
progress
)
{
var
last_promise
=
promise_list
[
promise_list
.
length
-
1
],
next_promise
;
if
(
this
.
isRejected
||
this
.
isFulfill
ed
)
{
if
(
resolv
ed
)
{
throw
new
ResolvedQueueError
();
}
next_promise
=
last_promise
.
then
(
done
,
fail
);
next_promise
=
last_promise
.
then
(
done
,
fail
,
progress
);
promise_list
.
push
(
next_promise
);
// Handle pop
promise_list
.
push
(
next_promise
.
then
(
function
(
fulfillmentValue
)
{
last_promise
=
next_promise
.
then
(
function
(
fulfillmentValue
)
{
promise_list
.
splice
(
0
,
2
);
if
(
promise_list
.
length
===
0
)
{
fulfill
(
fulfillmentValue
);
...
...
@@ -784,11 +830,19 @@ define("rsvp/queue",
return
fulfillmentValue
;
}
},
function
(
rejectedReason
)
{
if
(
!
(
promise
.
isRejected
||
promise
.
isFulfilled
))
{
promise_list
.
splice
(
0
,
2
);
if
(
promise_list
.
length
===
0
)
{
reject
(
rejectedReason
);
}
else
{
throw
rejectedReason
;
}
throw
rejectedReason
;
}));
},
function
(
notificationValue
)
{
if
(
promise_list
[
promise_list
.
length
-
1
]
===
last_promise
)
{
notify
(
notificationValue
);
}
return
notificationValue
;
});
promise_list
.
push
(
last_promise
);
return
this
;
};
...
...
@@ -824,7 +878,17 @@ define("rsvp/resolve",
function
resolve
(
thenable
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
thenable
);
if
(
typeof
thenable
===
"
object
"
&&
thenable
!==
null
)
{
var
then
=
thenable
.
then
;
if
((
then
!==
undefined
)
&&
(
typeof
then
===
"
function
"
))
{
return
then
.
apply
(
thenable
,
[
resolve
,
reject
]);
}
}
return
resolve
(
thenable
);
},
function
()
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
thenable
.
cancel
();
}
});
}
...
...
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