add interfaces to retrieve cached data without a new request
This commit is contained in:
parent
3f173d70a2
commit
82248ccbaf
|
|
@ -106,6 +106,18 @@ function onGameUpdate(gameId, callback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCachedGame(gameId) {
|
||||||
|
if (gameId in games) {
|
||||||
|
return JSON.stringify(games[gameId].data);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCachedMeta() {
|
||||||
|
return JSON.parse(JSON.stringify(meta.games));
|
||||||
|
}
|
||||||
|
|
||||||
function onMetaUpdate(callback) {
|
function onMetaUpdate(callback) {
|
||||||
if (Object.keys(meta.listeners).length === 0) {
|
if (Object.keys(meta.listeners).length === 0) {
|
||||||
startMetaPoll(meta.lastModified);
|
startMetaPoll(meta.lastModified);
|
||||||
|
|
@ -403,6 +415,8 @@ module.exports = {
|
||||||
getGameMeta,
|
getGameMeta,
|
||||||
onGameUpdate,
|
onGameUpdate,
|
||||||
onMetaUpdate,
|
onMetaUpdate,
|
||||||
|
getCachedGame,
|
||||||
|
getCachedMeta,
|
||||||
sendUpdate,
|
sendUpdate,
|
||||||
getConnectionState,
|
getConnectionState,
|
||||||
onConnectionStateChanged,
|
onConnectionStateChanged,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue