Skip to content

Commit

Permalink
feat: Add attr.renderMode as alternative to using an attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Jan 3, 2024
1 parent 5ba8ae0 commit 1602cd9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/Bolero.Server/Html.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,12 @@ module Html =
/// preceded by the standard "html" doctype declaration.
/// </summary>
let doctypeHtml = DoctypeHtmlBuilder()

#if NET8_0_OR_GREATER
module attr =

let renderMode (mode: IComponentRenderMode) =
Attr(fun _ b i ->
b.AddComponentRenderMode(mode)
i)
#endif
3 changes: 2 additions & 1 deletion tests/Remoting.Client/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ let Display model dispatch =
}
}

[<BoleroRenderMode(BoleroRenderMode.Auto); Route "/{*path}">]
// [<BoleroRenderMode(BoleroRenderMode.Auto)>]
[<Route "/{*path}">]
type MyApp() =
inherit ProgramComponent<Model, Message>()

Expand Down
3 changes: 2 additions & 1 deletion tests/Remoting.Server/Startup.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ open Bolero.Tests.Remoting.Client
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Authentication.Cookies
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Components.Web
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
Expand All @@ -45,7 +46,7 @@ module Page =
``base`` { attr.href "/" }
}
body {
div { attr.id "main"; comp<MyApp> }
div { attr.id "main"; comp<MyApp> { attr.renderMode RenderMode.InteractiveAuto } }
script { attr.src "_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js" }
boleroScript
}
Expand Down

0 comments on commit 1602cd9

Please sign in to comment.