Instantly share code, notes, and snippets.

Embed
What would you like to do?
<apex:page controller="Thingy">
This blank canvas with our controller applied lets us invoke the remoting methods from the dev console via:
<ul>
<li><code>Thingy.regularLimits(function(response){console.log('Regular limits are:',response);});</code></li>
<li><code>Thingy.readOnlyLimits(function(response){console.log('Regular limits are:',response);});</code></li>
</ul>
</apex:page>
public class Thingy{
@RemoteAction
public static Map<String,Integer> regularLimits(){
return getLimitsData();
}
@ReadOnly
@RemoteAction
public static Map<String,Integer> readOnlyLimits(){
return getLimitsData();
}
private static Map<String,Integer> getLimitsData(){
return new Map<String,Integer>{
'getLimitCallouts()' => Limits.getLimitCallouts(),
'getLimitCpuTime()' => Limits.getLimitCpuTime(),
'getLimitDMLRows()' => Limits.getLimitDMLRows(),
'getLimitDMLStatements()' => Limits.getLimitDMLStatements(),
'getLimitFutureCalls()' => Limits.getLimitFutureCalls(),
'getLimitHeapSize()' => Limits.getLimitHeapSize(),
'getLimitQueries()' => Limits.getLimitQueries(),
'getLimitQueries()' => Limits.getLimitQueries(),
'getLimitQueryRows()' => Limits.getLimitQueryRows(),
'getLimitScriptStatements()' => Limits.getLimitScriptStatements(),
'getLimitSoslQueries()' => Limits.getLimitSoslQueries()
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment