diff --git a/src/BlazeKit.Site/Pages/Reactivity/Basic/Page.razor b/src/BlazeKit.Site/Pages/Reactivity/Basic/Page.razor index 91fd9a1..3550e3a 100644 --- a/src/BlazeKit.Site/Pages/Reactivity/Basic/Page.razor +++ b/src/BlazeKit.Site/Pages/Reactivity/Basic/Page.razor @@ -123,24 +123,30 @@
 
 @@code {
-    // Create a Signal
-    @AsHtml("ISignal counter = new BlzState(0, this)").Value
-    @AsHtml(@"// Create a derived State
-    ISignal doubled =
-        new Derived(
-            () => counter.Value * 2,
-            this
-        );").Value
-    @AsHtml(@"// Create an Effect
-    new Effect(() => {
-            if(counter.Value > 0 && counter.Value % 5 == 0)
-            {
-                // since booms in not a signal, we need to notify the UI manually
-                // this is required if the counter updates in background task
-                booms++;
-            }
-        }
-    );").Value
+    @AsHtml(@"protected override void OnInitialized()
+    {
+        // Create a Signal
+        this.counter = new State(0, this);
+        // Create a derived State
+        this.doubled =
+            new Derived(
+                () => counter.Value * 2,
+                this
+            );
+        // Create an Effect
+        this.sideEffect =
+            new Effect(() =>
+                {
+                    if(counter.Value > 0 && counter.Value % 2 == 0)
+                    {
+                        // since booms in not a signal, we need to notify the UI manually
+                        // this is required if the counter updates in background task
+                        booms++;
+                        InvokeAsync(StateHasChanged);
+                    }
+                }
+            );
+    }").Value
 }
 
 @AsHtml("

@counter.Value

").Value diff --git a/vercel.json b/vercel.json index 2519a54..e7f1cd3 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,11 @@ { "buildCommand": "dotnet build ; dotnet publish ./src/BlazeKit.Site", "installCommand": "rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm ; yum -y install dotnet-sdk-7.0 ; dotnet --version", - "outputDirectory": ".vercel/output/static" + "outputDirectory": ".vercel/output/static", + "rewrites": [ + { + "source": "/(.*)", + "destination": "/index.html" + } + ] }