ReactGenie Functions
ReactGenie provides developers with auto-generated functions to assist in the implementation of multimodal interactive applications. These functions help to reduce the workload and enhance development efficiency.
setup()
The setup function is a static function of the GenieClass. Developers can override the setup function for initial program setup. It is generally used for initial data import and instantiation. ReactGenie will automatically call the setup function to complete the initialization. For example:
static setup() {
Counter.CreateObject({ name: "potato", counterType: "vegetable" });
Counter.CreateObject({ name: "apple", counterType: "fruit" });
Counter.CreateObject({ name: "banana", counterType: "fruit" });
Counter.CreateObject({ name: "orange", counterType: "fruit" });
Counter.CreateObject({ name: "grape", counterType: "fruit" });
Counter.CreateObject({ name: "mango", counterType: "fruit" });
Counter.CreateObject({ name: "pineapple", counterType: "fruit" });
Counter.CreateObject({ name: "strawberry", counterType: "fruit" });
Counter.CreateObject({ name: "watermelon", counterType: "fruit" });
}The call order of Setup is uncertain. If the initialization process needs to strictly follow the execution order, for example, if the property of dataclass B contains dataclass A, you need to complete the initialization of A before completing the initialization of B. In such cases, please build a static manual_setup function and manually set up the call order after initReactGenie().
export const orderStore = initReactGenie();
Restaurant.manual_setup();
FoodItem.manual_setup();
Order.manual_setup();CreateObject()
CreateObject() is a static member of the GenieClass. All instances of GenieClass must be created using CreateObject(), which automatically invokes the class constructor and sets getters and setters for the properties within it. Please refrain from directly using new Class().
Counter.CreateObject({ name: "potato", counterType: "vegetable" });Please note that you should not use CreateObject() in the prompt examples. We recommend you create your own creator as follows.
@GenieFunction
static CreateCounter({name, counterType}:{name: string, counterType: string}) : Counter{
return Counter.CreateObject({ name: name, counterType: counterType })
};GetObject()
GetObject() is automatically generated by ReactGenie. Only instances of dataclass can be accessed by GetObject() with its key.
Counter coin_count = Counter.GetObject({name:"Coin"});@GenieFunction()
static GetCounter({name = ""}: {name?: string}): Counter {
return Counter.GetObject({name: name});
}
DeleteObject()
The DeletedObject() is automatically generated by ReactGenie. Only instances of the dataclass can be accessed by GetObject() using its key. The return value is the object that is to be deleted.
let coin_count = Counter.DeleteObject({name:"Coin"});You can create your own deleter as follows:
DeleteCounter(): void {
this.DeleteObject({name:this.name});
};Current()
Current() retrieves the currently active target and is dynamically updated based on user clicks. Current() is automatically generated by rg and developers do not need to implement this function. Only dataclass has the Current().
//User click on Coin Counter
Counter.Current().count //5All()
All() retrieves an array of all instances of a specific class. All() is automatically generated by rg and developers do not need to implement this function. Only dataclass has the All(). For example:
Order.All().filter((order) => {
return !order.orderPlaced;
})