Skip to content

Instantly share code, notes, and snippets.

@wircho
Created June 4, 2015 14:27
Show Gist options
  • Save wircho/1e3a986e58fcee34014c to your computer and use it in GitHub Desktop.
Save wircho/1e3a986e58fcee34014c to your computer and use it in GitHub Desktop.
REL ( https://github.com/relevant-ai/RelevantCardsDocumentation ): How to load a web service, or any variable, only if more than 2 seconds have passed since last time it was loaded.
{
"_MAIN":{
"info":{
"time":{"_DATE":{"_FORMAT_OUT":"<<timestamp>>"}},
"var":"This is the variable. Here you put your API call, your _URL, whatever you need to call no less than 2 seconds in between every call."
},
"get_var":{
"_FUNCTION":{
"_IF":{"_MATH":[{"_DATE":{"_FORMAT_OUT":"<<timestamp>>"}},"-",{"_PATH":["info","time"]},">2"]},
"_THEN":{"_REFETCH":["info"],"_RETURN":{"_PATH":["info","var"]}},
"_ELSE":{"_PATH":["info","var"]}
}
}
"_LOAD":{
"var":{"_APPLY":"get_var"},
"//":"Use var here for _LOAD purposes..."
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment