Sheet - guiled/LRE GitHub Wiki
Sheets
LRE methods
get() is cached
sheet.get(id: string)
This method works like the method from Let's Role, but it is cached. You will always get the same object if you ask for a particular component (while Let's Role 's sheet.get() will return a different object).
You can manually handle the component cache with sheet.remember()
and sheet.forget()
.
find()
sheet.find(id: string)
In order to make sheet looks like a component, LRE provides the method find()
which is an alias of get()
componentExists
sheet.componentExists(id: string): boolean
This useful method can check if a component exists in a sheet. This tests doesn't rise error in the console.
setData
sheet.setData(data: Object)
This is one of the first feature that motivated the creation of LRE. You won't have to bother to split the data into 20-key-batches. This method is used like the one from Let's Role.
Let's Role block the number of data at 20 keys. So everyone had to code its own data sender. LRE provides its own here, doing it asynchronously : instead of sending many batches of 20 key/value pairs at once, LRE sends each batch in a very short delay (few milliseconds), that prevents the sheet UI to be blocked by a long script. Moreover, it can seem softer for the Let's Role server to do like that instead of sending all at once very shortly.
The drawbacks is that you can lose data if you close your browser tab very shortly after a modification. This case should be very rare and can be considered as a normal behavior (closing a tab less than 50ms after having changed an input).
sendPendingDataFor
sheet.sendPendingDataFor(id: string)
If you need, in a very specific case, to send to the server the data, without waiting the 50ms delay, you can use this method. The data will be immediately sent and be processed by Let's Role servers.
getPendingData
sheet.getPendingData(id: string): any
You can have access to the value of a component that is not already sent to the Let's Role 's servers by using this method.
group
sheet.group(id, components?: string[]): Group
Initiate a Group with the id
as first argument, and an optional list of component ids.
The group id must not be an id of an existing component or group.
persistingData, deletePersistingData
`sheet.persistingData(dataName: string, dataValue: any);
LRE provides a way to save any other data for the sheet, without the need of a component. This can be useful to store the version of your system in order to handle version migrations, or a Rule book version. You are totally free.
isInitialized
sheet.isInitialized(): boolean
This method gives the value returned by firstInit
if it exists. See firstInit doc.
getSheetAlphaId
This method returns the sheet id (returned by sheet.getSheetId()) in an alphabetic way. This can be useful to reference the sheet as a tag in a roll formula