By default SQRL functions cannot be used as statements. They need to either be used in calculating a feature or a rule.
Statement functions allow you to register functions that can act as entire statements. For example you might want to implement a statement that writes out a file during SQRL execution:
1 | writeFile("last-username.txt", Username); |
By default when you start up a SQRL execution nothing is run. Calling execution.fetchFeature
will start calculating that feature and any dependant ones.
Running statements uses special Statement Features such as SqrlFileStatements
below. These features always evaluate to true
, however their promise will only be resolved once all the statements have been run. If you want an execution to run all statements you can fetch the magic feature SqrlExecutionComplete
.
1 | const writeFileAsync = util.promisify(fs.writeFile); |
By default in a SQRL execution no statements are run.
In the example above execution.fetchFeature('SqrlFileStatements')
will cause all writeToFile statements to be called. By default SqrlExecutionComplete
includes all the special statement features, and that is loaded before any mutations are run.