What is Trevo App Development?
Trevo app development is the creation of a single Trevo file containing both front and back logic. It uses Trevo Code with two main parts:
- Front: for the UI and user interaction
- Back: for backend logic and functions
Comment Syntax
// This is a line comment
/* This is a multi-line comment */
Basic Structure
Front() {
//frontend code
}
Back() {
var a = "a";
function hello(parameters) {
return parameters + a;
}
}
Back with Variables and Functions
Front() {
//frontend code
}
Back() {
var a = "a";
function hello(parameters) {
return parameters + a;
}
}
Pages in Front
Front() {
page main() {
}
page otherpage() {
}
}
Back() {
var a = "a";
function hello(parameters) {
return parameters + a;
}
}
Using JSX in Front
Front() {
page main() {
<div onClick={(e)=>hello()}>
//jsx code
</div>
}
page otherpage() {
//jsx code
}
}
Back() {
var a = "a";
function hello(parameters) {
return parameters + a;
}
}
Global Variable: trevo
trevo.username - gets the username of the user
trevo.friends - gets the user's friend list
Storage Examples
trevo.appStorage.set("key", "value");
trevo.appStorage.get("key");
trevo.userStorage.set("key", "value");
trevo.userStorage.get("key");
trevo.appsharedStorage.set("key", "value");
trevo.appsharedStorage.get("key");
trevo.appsharedStorage.access("AppName", "key");
trevo.usersharedStorage.set("key", "value");
trevo.usersharedStorage.get("key");
trevo.usersharedStorage.access("AppName", "key");
Full Example
Front() {
page main() {
<div onClick={(e)=>hello()}>
{trevo.appsharedStorage.access("Message", "lastOpened")}
</div>
}
page otherpage() {
<div>my name is {trevo.username}</div>
}
}
Back() {
var a = "a";
function hello(parameters) {
return parameters + a;
}
}