21 lines
No EOL
691 B
JavaScript
21 lines
No EOL
691 B
JavaScript
|
|
// monkeypath Session.current to memoize
|
|
var original = Parse.Session.current
|
|
Parse.Session.current = async (original) => {
|
|
let delay = 400
|
|
if( Parse.Session.group != undefined ){
|
|
//console.log("caching request for "+delay+" ms")
|
|
return new Promise( (resolve,reject) => Parse.Session.group.push(resolve) )
|
|
}
|
|
Parse.Session.group = []
|
|
return new Promise( async (resolve,reject) => {
|
|
Parse.Session.group.push(resolve)
|
|
var res = await original()
|
|
setTimeout( () => {
|
|
Parse.Session.group.map( (r) => r(res) )
|
|
delete Parse.Session.group
|
|
},delay)
|
|
|
|
})
|
|
}
|
|
Parse.Session.current = Parse.Session.current.bind(Parse.Session,original) |