| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using Statum;
- using Invercargill;
- using Invercargill.DataStructures;
- namespace Example {
- // Typed slot models — GObject properties mapped to/from Properties via
- // GObjectMapping. ActionDto fields round-trip as nested JSON.
- public class CounterPrivate : Object {
- public int delta { get; set; }
- }
- public class CounterPublic : Object {
- public int value { get; set; }
- public Model.ActionDto bump { get; set; }
- }
- public class PagePublic : Object {
- public Model.ActionDto login { get; set; }
- }
- public class AuthPublic : Object {
- public string name { get; set; }
- public string role { get; set; }
- public Model.ActionDto logout { get; set; }
- }
- public class AuthPrivate : Object {
- public bool is_admin { get; set; }
- }
- /**
- * Entrypoint for the home page: hydrates counter + page slots with typed
- * models, embedding action references as fields.
- */
- public class HomeEntrypoint : StatumEntrypoint {
- public override async DirectiveBuilder handle() throws GLib.Error {
- var bump_private = new CounterPrivate();
- bump_private.delta = 1;
- var bump_ref = action_registry.author_private<BumpCounterAction, CounterPrivate>(bump_private);
- var counter = new CounterPublic();
- counter.value = 0;
- counter.bump = bump_ref;
- var page = new PagePublic();
- page.login = action_registry.author<LoginAction>();
- return directives()
- .set_typed<CounterPublic>("counter", Scope.PAGE, counter)
- .set_typed<PagePublic>("page", Scope.PAGE, page);
- }
- }
- /**
- * Entrypoint for the guarded dashboard page.
- */
- public class DashboardEntrypoint : StatumEntrypoint {
- public override async DirectiveBuilder handle() throws GLib.Error {
- return directives().notify("info", "Welcome to your dashboard");
- }
- }
- }
|