-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a quick start example to of a simple ReactivePage class which searches for a script named main.jsx that takes a single prop. From here, you're best to redefine the GetDatabase function or change it for your database and then replace main.jsx with your UI code.
- Loading branch information
1 parent
3ed9cbb
commit f995d3a
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Threading; | ||
|
||
namespace FAP | ||
{ | ||
internal class Example | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
ReactivePage.DownloadScripts(); //This line is necessary if you have not downloaded scripts | ||
Index page = new Index(); | ||
Server server = new Server(new[] { page }); | ||
for(;;) Thread.Sleep(-1); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// This is the current basic cookie cutter of a FAP.ReactivePage | ||
/// Name this class the same as the Component name found in whatever script | ||
/// Using "nameof" allows you to rename everything C# side fairly quickly, right click and rename | ||
/// </summary> | ||
public class Index : ReactivePage | ||
{ | ||
public Index() : base(nameof(Index), null) //This constructor will actually be called by FAP.Server | ||
{ //Which isn't great, but all these functions are idempotent | ||
Engine.MinimiseBabelOutput = false; | ||
IncludeScript("main.jsx"); //Since this library is meant for cross platform and so more than one IDE | ||
IncludeCSS("css/main.css"); //Input files cannot be defined within the project or project files | ||
IncludeCSS("css/xbbcode.css"); //It must be defined in the code | ||
//IsSPA = true; //Due to the maturity of the IsSPA functionality, it's now set true as default | ||
get = GetDatabase; //For proficient, safe development, this should be set with a state machine | ||
//(this as Page).get = (a,b) => JsonConvert.SerializeObject(GetDatabase(a,b)); //This also works, but why both? | ||
} | ||
|
||
public object GetDatabase(string a, string b) | ||
{ | ||
return (new { name = "not the Computer, but in fact " + a }); | ||
} | ||
} | ||
|
||
|
||
} |