HomeEntrypoint.vala 1.0 KB

123456789101112131415161718192021222324252627282930
  1. using Statum;
  2. using Invercargill;
  3. using Invercargill.DataStructures;
  4. namespace Example {
  5. /**
  6. * Entrypoint for the home page: hydrates a `counter` slot the template binds
  7. * to with `stm-text="counter.value"`.
  8. */
  9. public class HomeEntrypoint : StatumEntrypoint {
  10. public override async Lot<Model.DirectiveDto> handle() throws GLib.Error {
  11. var directives = new Series<Model.DirectiveDto>();
  12. var counter_public = new PropertyDictionary();
  13. counter_public.set_native<int>("value", 42);
  14. var counter_state = new State() {
  15. type_name = "counter",
  16. public_data = counter_public,
  17. private_data = new PropertyDictionary()
  18. };
  19. var counter_slot = state_service.new_slot(Scope.PAGE, counter_state);
  20. var counter_frame = state_service.sign_slot(counter_slot.id);
  21. directives.add(new Model.SetDirectiveDto.with_frame((!)counter_frame));
  22. return directives;
  23. }
  24. }
  25. }